ϪfdZddlmZddlmZ ddlmZdZddlm Z ddl m Z m Z ddl mZdd Zd j!d e j"d d j%dDZe dZeeneZddlmZddlmZddlmZmZesdZeduxsedvZde eZ!esddlm"Z"GddeeZ#y#e$rdZdZYMwxYw)z\ GObject Introspection reactor tests; i.e. `gireactor` module for gio/glib/gtk integration. ) annotations)skipIf)GioT)environ)get_required_versionrequire_version) gireactorc` td|y#t$r}t|cYd}~Sd}~wwxYw)NGtk)r ValueErrorstr) someVersionves F/usr/lib/python3/dist-packages/twisted/internet/test/test_gireactor.py requireEachrs1  E; / r7N s  - (--z, c#2K|]}t|yw)N)r).0versions r r"s  GsTWISTED_TEST_GTK_VERSIONz4.0,3.0,r NF)ReactorAlreadyRunning)ReactorBuilder)SkipTestTestCasez0GObject Introspection `gi` module not importable)z3.0z4.0zUnknown GTK version: )r ceZdZdZ d dZd dZeeed dZ eeed dZ d dZ d dZ d dZ d d Zy ) GApplicationRegistrationTestsa GtkApplication and GApplication are supported by L{twisted.internet.gtk3reactor} and L{twisted.internet.gireactor}. We inherit from L{ReactorBuilder} in order to use some of its reactor-running infrastructure, but don't need its test-creation functionality. ct|ds tdgd fd d fd }|jd||jj |t j ||jddgy) z Register the app, run the reactor, make sure app was activated, and that reactor was running, and that reactor can be stopped. quitz Version of PyGObject is too old.cHjdjy)Nstopped)appendstop)reactorresultsrr$z6GApplicationRegistrationTests.runReactor..stopRs MM) $ LLNcLjdjdy)N activatedr)r# callLater)widgetr%r&r$s ractivatez:GApplicationRegistrationTests.runReactor..activateVs MM+ &   a &r'r,r)r"NreturnNone)r+objectr.r/)hasattrrconnectholdregisterGApplicationr runReactor assertEqual)selfappr%r,r&r$s ` @@rr5z(GApplicationRegistrationTests.runReactorDsxsF#=> >  ' J)  $$S)!!$0 +y!9:r'cd|_|j}tjdtjj }|j ||y)zR L{Gio.Application} instances can be registered with a gireactor. c.tjdSNF)useGtkr GIReactorr'rzIGApplicationRegistrationTests.test_gApplicationActivate..ji&9&9&Gr'!com.twistedmatrix.trial.gireactorapplication_idflagsN)reactorFactory buildReactorr ApplicationApplicationFlags FLAGS_NONEr5r7r%r8s rtest_gApplicationActivatez7GApplicationRegistrationTests.test_gApplicationActivatefsKH##%oo>&&11  W%r'c^ddlm}m}m}|j |t j |j |t j|j |t j|j}|jt|d|jd|ddy)z L{twisted.internet.gtk3reactor} is now just a set of compatibility aliases for L{twisted.internet.GIReactor}. r) Gtk3ReactorPortableGtk3Reactorinstallz+twisted.internet.gtk3reactor was deprecatedmessageN) twisted.internet.gtk3reactorrNrOrPassertIsr r>PortableGIReactor flushWarningsr6lenassertIn)r7rNrOrPwarningss rtest_gtkAliasesz-GApplicationRegistrationTests.test_gtkAliasesss   k9#6#67 )9+F+FG gy001%%' X* 98A;y;Q r'ctj|_|j}t j dt jj}|j||y)zT L{Gtk.Application} instances can be registered with a gtk3reactor. z#com.twistedmatrix.trial.gtk3reactorrCN) r r>rFrGr rHrrIrJr5rKs rtest_gtkApplicationActivatez9GApplicationRegistrationTests.test_gtkApplicationActivatesP (11##%oo@&&11  W%r'ctj|_|j}t j dtj j}|jt|j|y)zo L{gireactor.PortableGIReactor} doesn't support application registration at this time. rBrCN) r rUrFrGrrHrIrJ assertRaisesNotImplementedErrorr4rKs r test_portablez+GApplicationRegistrationTests.test_portables[ (99##%oo>&&11  -w/K/KSQr'cd|_|j}t}|jt|j |}|j |jdjdy)zp Older versions of PyGObject lack C{Application.quit}, and so won't allow registration. c.tjdSr;r=r?r'rr@z;GApplicationRegistrationTests.test_noQuit..rAr'rzApplication registration is notN) rFrGr0r^ RuntimeErrorr4 assertTrueargs startswith)r7r%r8excs r test_noQuitz)GApplicationRegistrationTests.test_noQuits\ H##%h g.J.JCP  ../PQRr'cd_jtjdtjj dfd }j d|tjy)zp It is not possible to register a C{Application} after the reactor has already started. c.tjdSr;r=r?r'rr@zIGApplicationRegistrationTests.test_cantRegisterAfterRun..rAr'rBrCcjtj}j|jddj y)Nrz5Can't register application after reactor was started.)r^rr4r6rer$)rgr8r%r7s r tryRegisterzLGApplicationRegistrationTests.test_cantRegisterAfterRun..tryRegistersI##%w'C'CSC    T  LLNr'rNr-) rFrGrrHrIrJr*rr5)r7rlr8r%s` @@rtest_cantRegisterAfterRunz7GApplicationRegistrationTests.test_cantRegisterAfterRunsc H##%oo>&&11    ![)!!$0r'cd|_|j}tjdtjj }|j |tjdtjj }|jt|j |}|j|jddy)zN It is not possible to register more than one C{Application}. c.tjdSr;r=r?r'rr@zFGApplicationRegistrationTests.test_cantRegisterTwice..rAr'rBrCz"com.twistedmatrix.trial.gireactor2rz2Can't register more than one application instance.N) rFrGrrHrIrJr4r^rcr6re)r7r%r8app2rgs rtest_cantRegisterTwicez4GApplicationRegistrationTests.test_cantRegisterTwicesH##%oo>&&11  $$S)?&&11  g.J.JDQ  HHQKM r'N)r8zGio.Applicationr%zgireactor.GIReactorr.r/r-)__name__ __module__ __qualname____doc__r5rLr noGtkSkip noGtkMessagerZr\r`rhrmrqr?r'rrr:sz ;  ;% ;  ;D & I|$ % ( I|$ &% & R S10 r'r)rrr.r)$ru __future__runittestr gi.repositoryr giImportedosrgirrtwisted.internetr rjoingetsplit errorMessage actualVersion gtkVersion ImportErrortwisted.internet.errorr#twisted.internet.test.reactormixinsrtwisted.trial.unittestrrskiprvreprrwr rr?r'rrs#N! J8*99"w{{#=yIOOPSTL )/M"/";J9>5 =D 4  FZ~%E &tJ'7&89 !^ NH^ YJJsB88 CC