+
    Dfj                       R t ^ RIHt ^ RIHt  ^ RIHt Rt^ RIH	t	 ^ RI
HtHt ^ RIHt R R	 ltR
P!                  R ]	P"                  ! RR4      P%                  R4       4       4      t]! R4      t]e   ]M]t^ RIHt ^ RIHt ^ RIHtHt ]'       g   Rt]RJ ;'       g    ]R9  tR] ! ]4       2t!]'       g   ^ RIH"t"  ! R R]]4      t#R#   ] d    RtRt Lci ; i)z\
GObject Introspection reactor tests; i.e. `gireactor` module for gio/glib/gtk
integration.
)annotations)skipIf)GioT)environ)get_required_versionrequire_version)	gireactorc                    V ^8  d   QhRRRR/# )   someVersionstrreturn )formats   "F/usr/lib/python3/dist-packages/twisted/internet/test/test_gireactor.py__annotate__r      s            c                f     \        R V 4       R#   \         d   p\        T4      u Rp?# Rp?ii ; i)Gtk N)r   
ValueErrorr   )r   ves   & r   requireEachr      s1    	E;/   	r7N	s    0
+00z, c              #  8   "   T F  p\        V4      x  K  	  R # 5i)N)r   ).0versions   & r   	<genexpr>r   "   s      TG 	GTs   TWISTED_TEST_GTK_VERSIONz4.0,3.0,r   NF)ReactorAlreadyRunning)ReactorBuilder)SkipTestTestCasez0GObject Introspection `gi` module not importablezUnknown GTK version: )r   c                      ] tR t^:tRtR R ltR R lt]! ]]	4      R R l4       t
]! ]]	4      R R	 l4       tR
 R ltR R ltR R ltR R ltRtR# )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.
c               $    V ^8  d   QhRRRRRR/# )r
   appzGio.Applicationreactorzgireactor.GIReactorr   Noner   )r   s   "r   r   *GApplicationRegistrationTests.__annotate__D   s(      ;  ; ; % ; 
	 ;r   c                0  aaa \        VR4      '       g   \        R4      h. oR VV3R lloR VVV3R llpVP                  RV4       VP                  4        SP	                  V4       \
        P                  ! V S4       V P                  SRR	.4       R
# )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.c                   V ^8  d   QhRR/# r
   r   r(   r   )r   s   "r   r   >GApplicationRegistrationTests.runReactor.<locals>.__annotate__R   s     	 	d 	r   c                 J   < SP                  R 4       S P                  4        R# )stoppedN)appendstop)r'   results   r   r2   6GApplicationRegistrationTests.runReactor.<locals>.stopR   s    MM)$LLNr   c                    V ^8  d   QhRRRR/# )r
   widgetobjectr   r(   r   )r   s   "r   r   r.   V   s     	' 	'V 	' 	'r   c                N   < SP                  R 4       SP                  ^ S4       R# )	activatedN)r1   	callLater)r6   r'   r3   r2   s   &r   activate:GApplicationRegistrationTests.runReactor.<locals>.activateV   s    MM+&a&r   r;   r9   r0   N)hasattrr!   connectholdregisterGApplicationr    
runReactorassertEqual)selfr&   r'   r;   r3   r2   s   &&f @@r   rA   (GApplicationRegistrationTests.runReactorD   s     sF##=>>	 		' 	' 	J) 	
$$S)!!$0+y!9:r   c                   V ^8  d   QhRR/# r-   r   )r   s   "r   r   r)   f   s     & &4 &r   c                    R V n         V P                  4       p\        P                  ! R\        P                  P
                  R7      pV P                  W!4       R# )zB
L{Gio.Application} instances can be registered with a gireactor.
c                 0    \         P                  ! R R7      # F)useGtkr   	GIReactorr   r   r   <lambda>IGApplicationRegistrationTests.test_gApplicationActivate.<locals>.<lambda>j       i&9&9&Gr   !com.twistedmatrix.trial.gireactorapplication_idflagsN)reactorFactorybuildReactorr   ApplicationApplicationFlags
FLAGS_NONErA   rC   r'   r&   s   &  r   test_gApplicationActivate7GApplicationRegistrationTests.test_gApplicationActivatef   sI     H##%oo>&&11

 	%r   c                   V ^8  d   QhRR/# r-   r   )r   s   "r   r   r)   t   s     
 
 
r   c                p   ^ RI HpHpHp V P	                  V\
        P                  4       V P	                  V\
        P                  4       V P	                  V\
        P                  4       V P                  4       pV P                  \        V4      ^4       V P                  RV^ ,          R,          4       R# )zo
L{twisted.internet.gtk3reactor} is now just a set of compatibility
aliases for L{twisted.internet.GIReactor}.
)Gtk3ReactorPortableGtk3Reactorinstallz+twisted.internet.gtk3reactor was deprecatedmessageN)twisted.internet.gtk3reactorr]   r^   r_   assertIsr   rK   PortableGIReactorflushWarningsrB   lenassertIn)rC   r]   r^   r_   warningss   &    r   test_gtkAliases-GApplicationRegistrationTests.test_gtkAliasess   s    	
 	
 	k9#6#67)9+F+FGgy001%%'X*98A;y;Q	
r   c                   V ^8  d   QhRR/# r-   r   )r   s   "r   r   r)      s     
& 
&T 
&r   c                    \         P                  V n        V P                  4       p\        P
                  ! R\        P                  P                  R7      pV P                  W!4       R# )zD
L{Gtk.Application} instances can be registered with a gtk3reactor.
z#com.twistedmatrix.trial.gtk3reactorrP   N)
r   rK   rS   rT   r   rU   r   rV   rW   rA   rX   s   &  r   test_gtkApplicationActivate9GApplicationRegistrationTests.test_gtkApplicationActivate   sN    
 (11##%oo@&&11
 	%r   c                   V ^8  d   QhRR/# r-   r   )r   s   "r   r   r)      s     R Rt Rr   c                    \         P                  V n        V P                  4       p\        P
                  ! R\        P                  P                  R7      pV P                  \        VP                  V4       R# )zW
L{gireactor.PortableGIReactor} doesn't support application
registration at this time.
rO   rP   N)r   rc   rS   rT   r   rU   rV   rW   assertRaisesNotImplementedErrorr@   rX   s   &  r   test_portable+GApplicationRegistrationTests.test_portable   s[    
 (99##%oo>&&11
 	-w/K/KSQr   c                   V ^8  d   QhRR/# r-   r   )r   s   "r   r   r)      s     
S 
ST 
Sr   c                    R V n         V P                  4       p\        4       pV P                  \        VP
                  V4      pV P                  VP                  ^ ,          P                  R4      4       R# )zX
Older versions of PyGObject lack C{Application.quit}, and so won't
allow registration.
c                 0    \         P                  ! R R7      # rH   rJ   r   r   r   rL   ;GApplicationRegistrationTests.test_noQuit.<locals>.<lambda>   rN   r   zApplication registration is notN)	rS   rT   r7   rp   RuntimeErrorr@   
assertTrueargs
startswith)rC   r'   r&   excs   &   r   test_noQuit)GApplicationRegistrationTests.test_noQuit   s\    
 H##%hg.J.JCP../PQRr   c                   V ^8  d   QhRR/# r-   r   )r   s   "r   r   r)      s     1 14 1r   c                  a aa R S n         S P                  4       o\        P                  ! R\        P                  P
                  R7      oR VVV 3R llpSP                  ^ V4       \        P                  ! S S4       R# )zX
It is not possible to register a C{Application} after the reactor has
already started.
c                 0    \         P                  ! R R7      # rH   rJ   r   r   r   rL   IGApplicationRegistrationTests.test_cantRegisterAfterRun.<locals>.<lambda>   rN   r   rO   rP   c                   V ^8  d   QhRR/# r-   r   )r   s   "r   r   MGApplicationRegistrationTests.test_cantRegisterAfterRun.<locals>.__annotate__   s     	 	T 	r   c                    < SP                  \        SP                  S4      p SP                  V P                  ^ ,          R4       SP                  4        R# )    z5Can't register application after reactor was started.N)rp   r   r@   rB   rz   r2   )r|   r&   r'   rC   s    r   tryRegisterLGApplicationRegistrationTests.test_cantRegisterAfterRun.<locals>.tryRegister   sI    ##%w'C'CSC T LLNr   N)	rS   rT   r   rU   rV   rW   r:   r    rA   )rC   r   r&   r'   s   f @@r   test_cantRegisterAfterRun7GApplicationRegistrationTests.test_cantRegisterAfterRun   sh    
 H##%oo>&&11

	 	 	![)!!$0r   c                   V ^8  d   QhRR/# r-   r   )r   s   "r   r   r)      s     
 
 
r   c                   R V n         V P                  4       p\        P                  ! R\        P                  P
                  R7      pVP                  V4       \        P                  ! R\        P                  P
                  R7      pV P                  \        VP                  V4      pV P                  VP                  ^ ,          R4       R# )z>
It is not possible to register more than one C{Application}.
c                 0    \         P                  ! R R7      # rH   rJ   r   r   r   rL   FGApplicationRegistrationTests.test_cantRegisterTwice.<locals>.<lambda>   rN   r   rO   rP   z"com.twistedmatrix.trial.gireactor2z2Can't register more than one application instance.N)rS   rT   r   rU   rV   rW   r@   rp   rx   rB   rz   )rC   r'   r&   app2r|   s   &    r   test_cantRegisterTwice4GApplicationRegistrationTests.test_cantRegisterTwice   s     H##%oo>&&11
 	$$S)?&&11
 g.J.JDQHHQKM	
r   )rS   N)__name__
__module____qualname____firstlineno____doc__rA   rY   r   	noGtkSkipnoGtkMessagerh   rl   rr   r}   r   r   __static_attributes__r   r   r   r$   r$   :   sc     ;D& I|$
 %
( I|$
& %
&R
S10
 
r   r$   )z3.0z4.0)$r   
__future__r   unittestr   gi.repositoryr   
giImportedosr   gir   r   twisted.internetr   r   joingetspliterrorMessageactualVersion
gtkVersionImportErrortwisted.internet.errorr   #twisted.internet.test.reactormixinsr    twisted.trial.unittestr!   r"   skipr   reprr   r   r$   r   r   r   <module>r      s    # N!
 J8* 99 {{#=yIOOPST L
 )/M"/";J 9 > 5 =D4FFZ~%E	&tJ'7&89!^
NH ^
Y  JJs   C CC