+
    Dfj_                       R t ^ RIHt ^ RIt^ RIt^ RIt^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHtHtHt ^ RIHtHtHt ^ RIHt ^ R	IHtHt ^ R
IHtHtHt ^ RIHt ^ RI H!t!H"t"Ht ^ RI#H$t$ ^ RI%H&t& ^ RI'H(t( ^RI)H*t* ]'       d   ^ RI+H,t, R R lt- ! R R](P\                  4      t/R R lt0 ! R R](P\                  4      t1 ! R R](P\                  4      t2 ! R R]24      t3 ! R R](P\                  4      t4R# ) z"
Tests for loading tests by name.
)annotationsN)md5)
attrgetter)
ModuleType)TYPE_CHECKINGCallable	Generator)assert_thatequal_tohas_properties)Matcher)filepathutil)PythonAttributePythonModule	getModule)ModuleNotFound)reporterrunnerunittest)_iterateTests)	ITestCase)packages)after)SupportsRichComparisonc                    V ^8  d   QhRRRR/# )   tests"pyunit.TestCase | pyunit.TestSuitereturnz	list[str] )formats   "@/usr/lib/python3/dist-packages/twisted/trial/test/test_loader.py__annotate__r#   !   s      7 I     c                l    . p\        V 4       F"  pVP                  VP                  4       4       K$  	  V# )zA
Return the id of each test within the given test suite or case.
)r   appendid)r   namestests   &  r"   	testNamesr*   !   s/     Ee$TWWY %Lr$   c                  ^   a  ] tR t^+tR V 3R lltR R ltR R ltR R ltR	 R
 ltRt	V ;t
# )FinderPy3Testsc                   V ^8  d   QhRR/# r   r   Noner    )r!   s   "r"   r#   FinderPy3Tests.__annotate__,   s     * *t *r$   c                	X   < \         SV `  4        \        P                  ! 4       V n        R # N)supersetUpr   
TestLoaderloader)self	__class__s   &r"   r4   FinderPy3Tests.setUp,   s    '')r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r0   0   s     
 
D 
r$   c                \    V P                  \        V P                  P                  R4       R# )z
findByName, if given something findable up until the last entry, will
raise AttributeError (as it cannot tell if 'nonexistent' here is
supposed to be a module or a class).
ztwisted.trial.test.nonexistentN)assertRaisesAttributeErrorr6   
findByNamer7   s   &r"   test_findNonModule!FinderPy3Tests.test_findNonModule0   s$     	DKK224T	
r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r0   :   s     O OT Or$   c                	\    V P                  \        V P                  P                  R 4       R# )	nonextantN)r<   r   r6   r>   r?   s   &r"   test_findNonPackage"FinderPy3Tests.test_findNonPackage:   s    .$++*@*@+Nr$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r0   =   s     D D$ Dr$   c                    \         P                  ! \        R4      pV P                  \        V P
                  P                  V4       R# )zp
findByName, given a file path that doesn't exist, will raise a
ValueError saying that it is not a Python file.
znonexistent.pyN)r   sibpath__file__r<   
ValueErrorr6   r>   )r7   paths   & r"   test_findNonFileFinderPy3Tests.test_findNonFile=   s1    
 ||H&67*dkk&<&<dCr$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r0   E   s     
 
d 
r$   c                \    V P                  \        V P                  P                  R4       R# )zV
findByName will re-raise ImportErrors inside modules that it has found
and imported.
zunimportablepackage.test_moduleN)r<   ImportErrorr6   r>   r?   s   &r"   test_findFileWithImportError+FinderPy3Tests.test_findFileWithImportErrorE   s$    
 	//1R	
r$   r6   )__name__
__module____qualname____firstlineno__r4   r@   rE   rM   rR   __static_attributes____classcell__)r8   s   @r"   r,   r,   +   s(    * *
OD
 
r$   r,   c                    V ^8  d   QhRRRR/# )r   moduler   r   zMatcher[ModuleType]r    )r!   s   "r"   r#   r#   O   s     5 5Z 5,? 5r$   c                   V P                   pVf   Q h\        R\        VP                  4      R\	        \
        P                  \        \
        P                  ! VP                  4      4      4      /4      p\	        \        R4      V4      # )a  
Match a module with a L{ModuleSpec} like that of the given module.

@return: A matcher for a module spec that has the same name and origin as
    the given module spec, though the origin may be structurally inequal
    as long as it is semantically equal.
nameorigin__spec__)	r`   r   r
   r^   r   r   FilePathr_   r   )r\   expected
match_specs   &  r"   looselyResemblesrd   O   sv     H HX]]+e!!**8??;<	
J J'44r$   c                      ] tR t^gtRtR R ltR R ltR R ltR R	 ltR
 R lt	R R lt
R R ltR R ltR R ltRtR# )	FileTestsz'
Tests for L{runner.filenameToModule}.
c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   FileTests.__annotate__l   s     9 9d 9r$   c                    V P                  \        \        P                  R4      pV P	                  \        V4      R4       R# )zW
L{runner.filenameToModule} raises a C{ValueError} when a non-existing
file is passed.
itz'it' doesn't existN)r<   rK   r   filenameToModuleassertEqualstr)r7   errs   & r"   test_notFileFileTests.test_notFilel   s3    
 
F,C,CTJS#78r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   rh   t   s     + +4 +r$   c                    \         P                  ! \        P                  ! \        R4      4      p^ RIHp V P                  W!4       R# )zp
If the file in question is a module on the Python path, then it should
properly import and return that module.
z	sample.pysampleN)r   rk   r   rI   rJ   twisted.trial.testrt   rl   r7   sample1sample2s   &  r"   test_moduleInPathFileTests.test_moduleInPatht   s0    
 ))$,,x*MN8*r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   rh   ~   s     8 8d 8r$   c                   V P                  V P                  4       \        P                  ! \        P
                  P                  V P                  RR4      4      pV P                  VP                  R4       V P                  4        V P                  V P                  4       ^ RIHp V P                  W4       \        V\!        V4      4       R# )z
If passed the path to a file containing the implementation of a
module within a package which is not on the import path,
L{runner.filenameToModule} returns a module object loosely
resembling the module defined by that file anyway.
goodpackageztest_sample.pyzgoodpackage.test_sample)test_sampleN)mangleSysPatholdPathr   rk   osrL   joinparentrl   rU   cleanUpModulesnewPathr}   r~   assertIsNotr	   rd   rv   s   &  r"   test_moduleNotInPathFileTests.test_moduleNotInPath~   s     	4<<())GGLLm5EF
 	))+DE4<<(6*G-g67r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   rh      s     < <D <r$   c                    \         P                  ! \        P                  P	                  V P
                  R4      4      pV P                  V\        P                  R,          4       R# )zr
If the file in question is a package on the Python path, then it should
properly import and return that package.
r}   N)	r   rk   r   rL   r   r   assertIssysmodules)r7   package1s   & r"   test_packageInPathFileTests.test_packageInPath   s>    
 **277<<]+SThM :;r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   rh      s     = =t =r$   c                   V P                  V P                  4       \        P                  ! \        P
                  P                  V P                  R4      4      pV P                  VP                  R4       V P                  4        V P                  V P                  4       ^ RIpV P                  W4       \        V\        V4      4       R# )z
If passed the path to a directory which represents a package which
is not on the import path, L{runner.filenameToModule} returns a
module object loosely resembling the package defined by that
directory anyway.
r}   N)r   r   r   rk   r   rL   r   r   rl   rU   r   r   r}   r   r	   rd   )r7   r   r}   s   &  r"   test_packageNotInPathFileTests.test_packageNotInPath   s     	4<<(**277<<]+ST**M:4<<(/H.{;<r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   rh      s     
T 
T$ 
Tr$   c                4   \         P                  ! V P                  4      P                  R4      pVP	                  4        V P                  \        \        P                  VP                  4      pV P                  \        V4      VP                  : R24       R# )z
L{runner.filenameToModule} raises a C{ValueError} when the name of an
empty directory is passed that isn't considered a valid Python package
because it doesn't contain a C{__init__.py} file.
emptyDirectoryz is not a package directoryN)r   ra   r   childcreateDirectoryr<   rK   r   rk   rL   rl   rm   )r7   emptyDirrn   s   &  r"   test_directoryNotPackage"FileTests.test_directoryNotPackage   so     $$T[[1778HI  "
F,C,CX]]SShmm%66Q#RSr$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   rh      s     O O Or$   c                    \         P                  ! V P                  4      P                  R4      pVP	                  R4       V P                  \        \        P                  VP                  4       R# )zV
L{runner.filenameToModule} raises a C{SyntaxError} when a non-Python
file is passed.
	notpythons   This isn't pythonN)
r   ra   r   r   
setContentr<   SyntaxErrorr   rk   rL   )r7   filenames   & r"   test_filenameNotPython FileTests.test_filenameNotPython   sN    
 $$T[[177D01+v'>'>Nr$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   rh      s      T r$   c                   \         P                  ! V P                  4      P                  R4      pVP	                  \
        P                  P                  R4      4        \        P                  ! VP                  4      pV P                  VP                  VP                  4       VP                  4        R#   TP                  4        i ; i)zH
The C{__file__} attribute of the module should match the package name.
zgoodpackage.pyutf8N)r   ra   r   r   r   r   
testModuleencoder   rk   rL   rl   rJ   remove)r7   r   r\   s   &  r"   test_filenameMatchesPackage%FileTests.test_filenameMatchesPackage   s     $$T[[1778HIH//66v>?	,,X]];FX]]FOO<OOHOOs   AB7 7C	c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   rh      s       r$   c                v   \         P                  ! V P                  4      P                  R4      pVP	                  4        VP                  R4      P                  R4        \        P                  ! VP                  4      pV P                  VP                  P                  R4      4       \        P                  ! VP                  \        P                  P                  ,           4      pV P                  VP                  P                  R4      4       VP                  4        R#   TP                  4        i ; i)z
Test loader against a filesystem directory containing an empty
C{__init__.py} file. It should handle 'path' and 'path/' the same way.
goodDirectory__init__.pyr$   N)r   ra   r   r   r   r   r   rk   rL   
assertTruerU   endswithr   sepr   )r7   goodDirr\   s   &  r"   test_directoryFileTests.test_directory   s    
 ##DKK066G!m$//4	,,W\\:FOOFOO44_EF,,W\\BGGKK-GHFOOFOO44_EFNNGNNs   !B3D& &D8r    N)rU   rV   rW   rX   __doc__ro   ry   r   r   r   r   r   r   r   rY   r    r$   r"   rf   rf   g   s;    9+8*<=$
TO r$   rf   c                     ] tR t^tRtR R ltR R ltR R ltR R	 ltR
 R lt	R R lt
R R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR  R! ltR" R# ltR$ R% ltR& R' ltR( R) ltR* R+ ltR, R- ltR. R/ ltR0 R1 ltR2 R3 ltR4 R5 ltR6 R7 ltR8 R9 lt R: R; lt!R< R= lt"R> R? lt#R@t$RA# )BLoaderTestsz 
Tests for L{trial.TestLoader}.
c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   LoaderTests.__annotate__   s     1 1t 1r$   c                	x    \         P                  ! 4       V n        \        P                  P                  V 4       R # r2   )r   r5   r6   r   SysPathManglingTestr4   r?   s   &r"   r4   LoaderTests.setUp   s&    '')$$**40r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r      s     T T Tr$   c                	   a ^ RI Hp V P                  P                  VP                  4      pT P                  . ROVP                   Uu. uF  q3P                  NK  	  up4       . ROp\        \        V\        ^4      4      4      oV3R lV P                  n        V P                  P                  VP                  4      pT P                  YBP                   Uu. uF  q3P                  NK  	  up4       R# u upi u upi )    rs   c                D   < SP                  V P                  4       R4      # )   )getshortDescription)xsortDicts   &r"   <lambda>,LoaderTests.test_sortCases.<locals>.<lambda>   s    x||A4F4F4H"'Mr$   N)test_atest_btest_c)r   r   r   )ru   rt   r6   	loadClassAlphabetTestrl   _tests_testMethodNamedictziprangesorter)r7   rt   suiter)   newOrderr   s   &    @r"   test_sortCasesLoaderTests.test_sortCases   s    -%%f&9&9:*.3ll;ld!!l;	
 2HeAh/0M%%f&9&9:\\#R\T$8$8\#RS < $Ss   	C6
C;
c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r      s     2 2$ 2r$   c                
   V P                   P                  R4      p\        P                  ! 4       pVP	                  V4       V P                  VP                  ^4       V P                  \        VP                  4      ^4       R# )zc
Loading a test that fails and getting the result of it ends up with one
test ran and one failure.
z6twisted.trial.test.erroneous.TestRegularFail.test_failN)	r6   
loadByNamer   
TestResultrunrl   testsRunlenfailures)r7   r   results   &  r"   test_loadFailureLoaderTests.test_loadFailure   sd    
 &&D
 $$&		&!,V__-q1r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r     s     E Et Er$   c                   ^ RI Hp V P                  P                  VP                  P
                  VP                  . ROR7      pV P                  ^VP                  4       4       V P                  RVP                  4       R# )z
A decorated test method for which the decorator has failed to set the
method's __name__ correctly is loaded and its name in the class scope
discovered.
rs   test_badDecoratorr   qualNameN)rt   DecorationTestr   )	ru   rt   r6   loadAnythingr   r   rl   countTestCasesr   r7   rt   r   s   &  r"   test_loadBadDecorator!LoaderTests.test_loadBadDecorator  sm     	.((!!33((F ) 

 	E0023,e.C.CDr$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r     s     F F Fr$   c                   ^ RI Hp V P                  P                  VP                  P
                  VP                  . ROR7      pV P                  ^VP                  4       4       V P                  RVP                  4       R# )z
A decorated test method for which the decorator has set the method's
__name__ correctly is loaded and the only name by which it goes is used.
rs   test_goodDecoratorr   N)rt   r   r   )	ru   rt   r6   r   r   r   rl   r   r   r   s   &  r"   test_loadGoodDecorator"LoaderTests.test_loadGoodDecorator  sm    
 	.((!!44((G ) 

 	E0023-u/D/DEr$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r   %  s     I I4 Ir$   c                   ^ RI Hp V P                  P                  VP                  P
                  VP                  . ROR7      pV P                  ^VP                  4       4       V P                  RVP                  4       R# )z
Load a decorated method which has been copied to a new name inside the
class.  Thus its __name__ and its key in the class's __dict__ no
longer match.
rs   test_renamedDecoratorr   N)rt   r   r   )	ru   rt   r6   r   r   r   rl   r   r   r   s   &  r"   test_loadRenamedDecorator%LoaderTests.test_loadRenamedDecorator%  sm     	.((!!77((J ) 

 	E00230%2G2GHr$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r   5  s     
 
 
r$   c                	   ^ RI Hp V P                  P                  VP                  4      pV P                  ^VP                  4       4       T P                  RR.VP                   Uu. uF  q3P                  NK  	  up4       R# u upi )r   rs   test_bartest_fooN)	ru   rt   r6   r   FooTestrl   r   r   r   )r7   rt   r   r)   s   &   r"   test_loadClassLoaderTests.test_loadClass5  sh    -%%fnn5E0023$&U';';&U	
&Us   (B
c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r   >  s     L L4 Lr$   c                	   ^ RI Hp V P                  \        V P                  P
                  V4       V P                  \        V P                  P
                  VP                  P                  4       V P                  \        V P                  P
                  R4       V P                  \        V P                  P
                  R4       R# r   rs   stringN)foobar)ru   rt   r<   	TypeErrorr6   r   r   r   r7   rt   s   & r"   test_loadNonClassLoaderTests.test_loadNonClass>  s    -)T[[%:%:FC)T[[%:%:FNN<S<ST)T[[%:%:HE)T[[%:%:NKr$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r   F  s     N Nd Nr$   c                	|    ^ RI Hp V P                  \        V P                  P
                  VP                  4       R# r   rs   N)ru   rt   r<   rK   r6   r   NotATestr  s   & r"   test_loadNonTestCase LoaderTests.test_loadNonTestCaseF  s%    -*dkk&;&;V__Mr$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r   K  s     5 5 5r$   c                	    ^ RI Hp V P                  P                  V4      pV P	                  ^
VP                  4       4       R# r  )ru   rt   r6   
loadModulerl   r   r   s   &  r"   test_loadModuleLoaderTests.test_loadModuleK  s2    -&&v.U1134r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r   Q  s     M MD Mr$   c                	   ^ RI Hp V P                  \        V P                  P
                  VP                  4       V P                  \        V P                  P
                  VP                  P                  4       V P                  \        V P                  P
                  R4       V P                  \        V P                  P
                  R4       R# r  )ru   rt   r<   r  r6   r  r   r   r  s   & r"   test_loadNonModuleLoaderTests.test_loadNonModuleQ  s    -)T[[%;%;V^^L)T[[%;%;V^^=T=TU)T[[%;%;XF)T[[%;%;^Lr$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r   Y  s     4 4$ 4r$   c                	    ^ RI pV P                  P                  V4      pV P                  ^VP	                  4       4       R# r   Nr}   r6   loadPackagerl   r   r7   r}   r   s   &  r"   test_loadPackageLoaderTests.test_loadPackageY  s2    ''4E0023r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r   _  s     N NT Nr$   c                	   ^ RI Hp V P                  \        V P                  P
                  VP                  4       V P                  \        V P                  P
                  VP                  P                  4       V P                  \        V P                  P
                  R4       V P                  \        V P                  P
                  R4       R# r  )ru   rt   r<   r  r6   r  r   r   r  s   & r"   test_loadNonPackageLoaderTests.test_loadNonPackage_  s    -)T[[%<%<fnnM)T[[%<%<fnn>U>UV)T[[%<%<hG)T[[%<%<nMr$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r   g  s     F F$ Fr$   c                	h    ^ RI Hp V P                  \        V P                  P
                  V4       R# r  )ru   rt   r<   r  r6   r  r  s   & r"   test_loadModuleAsPackage$LoaderTests.test_loadModuleAsPackageg  s#    - 	)T[[%<%<fEr$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r   m  s     5 54 5r$   c                	    ^ RI pV P                  P                  VRR7      pV P                  ^VP	                  4       4       R# r   NTrecurser  r  s   &  r"   test_loadPackageRecursive%LoaderTests.test_loadPackageRecursivem  s7    ''T'BU1134r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r   s  s     
 
4 
r$   c                	    ^ RI Hp V P                  P                  V4      pV P	                  VP
                  VP                  ^ ,          P                  ^ ,          P                  P                  4       R# r  )	ru   rt   r6   r   rl   rU   r   r8   rV   r   s   &  r"   test_loadAnythingOnModule%LoaderTests.test_loadAnythingOnModules  sO    -((0OOU\\!_33A6@@KK	
r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r   {  s     4 4$ 4r$   c                	    ^ RI Hp V P                  P                  VP                  4      pV P                  ^VP                  4       4       R# r  )ru   rt   r6   r   r   rl   r   r   s   &  r"   test_loadAnythingOnClass$LoaderTests.test_loadAnythingOnClass{  s6    -((8E0023r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r     s     4 4D 4r$   c                	    ^ RI pV P                  P                  V4      pV P                  \	        W P                  P
                  4      4       V P                  ^VP                  4       4       R# r  r}   r6   r   r   
isinstancesuiteFactoryrl   r   r  s   &  r"   test_loadAnythingOnPackage&LoaderTests.test_loadAnythingOnPackage  sM    ((5
5++*B*BCDE0023r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r     s     5 5T 5r$   c                	    ^ RI pV P                  P                  VRR7      pV P                  \	        W P                  P
                  4      4       V P                  ^VP                  4       4       R# r,  r;  r  s   &  r"   #test_loadAnythingOnPackageRecursive/LoaderTests.test_loadAnythingOnPackageRecursive  sR    ((d(C
5++*B*BCDU1134r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r     s     N N4 Nr$   c                	\    V P                  \        V P                  P                  R 4       R# )r}   N)r<   r  r6   r   r?   s   &r"   test_loadAnythingOnString%LoaderTests.test_loadAnythingOnString  s      	)T[[%=%=}Mr$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r     s     
 
4 
r$   c                	   ^ RI pV P                  P                  VRR7      p\        P                  ! 4       pVP                  V4       V P                  RVP                  4       4       V P                  ^\        VP                  4      4       VP                   UUu. uF  w  rEVP                  4       NK  	  pppVP                  4        V P                  VRR.4       R# u uppi )r   NTr-  Fzpackage.test_bad_modulezpackage.test_import_module)packager6   r  r   Reporterr   rl   wasSuccessfulr   errorsr'   sort)r7   rJ  r   r   r)   errorrM  s   &      r"   test_importErrorsLoaderTests.test_importErrors  s    '''>""$		& 4 4 67C.//5}}=}$'')}=.0LM	
 >s   C c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r     s     0 0 0r$   c                     ! R R\         P                  4      pV P                  P                  V4      p\        P
                  ! 4       pVP                  V4       V P                  VP                  4       4       R# )z
L{TestLoader.loadClass} returns a suite with each test method
represented by a different instances of the L{TestCase} they are
defined on.
c                  .    ] tR tRtR R ltR R ltRtR# )>LoaderTests.test_differentInstances.<locals>.DistinctInstancesi  c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   KLoaderTests.test_differentInstances.<locals>.DistinctInstances.__annotate__  s     ( ( (r$   c                	    R V n         R# )test1RunNfirstr?   s   &r"   test_1ELoaderTests.test_differentInstances.<locals>.DistinctInstances.test_1  s	    '
r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   rW    s     9 9 9r$   c                	<    V P                  \        V R 4      4       R# )r[  N)assertFalsehasattrr?   s   &r"   test_2ELoaderTests.test_differentInstances.<locals>.DistinctInstances.test_2  s      w!78r$   rZ  N)rU   rV   rW   rX   r\  rb  rY   r    r$   r"   DistinctInstancesrU    s    (9 9r$   rd  N)	pyunitTestCaser6   r   r   rK  r   r   rL  )r7   rd  r   r   s   &   r"   test_differentInstances#LoaderTests.test_differentInstances  sX    	9 	9 %%&78""$		&,,./r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r     s     	H 	H 	Hr$   c                    ^ RI Hp V P                  P                  V4      pV P	                  ^ VP                  4       4       V P	                  R\        VRR4      4       R# )zX
Check that C{test_suite} is used when present and other L{TestCase}s are
not included.
)mockcustomsuiteMyCustomSuiter^   N)ru   rk  r6   r  rl   r   getattr)r7   rk  r   s   &  r"   test_loadModuleWith_test_suite*LoaderTests.test_loadModuleWith_test_suite  sM    
 	7&&7E0023'%*FGr$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r     s     	H 	Ht 	Hr$   c                    ^ RI Hp V P                  P                  V4      pV P	                  ^ VP                  4       4       V P	                  R\        VRR4      4       R# )zW
Check that C{testSuite} is used when present and other L{TestCase}s are
not included.
mockcustomsuite2rl  r^   N)ru   rs  r6   r  rl   r   rm  )r7   rs  r   s   &  r"   test_loadModuleWith_testSuite)LoaderTests.test_loadModuleWith_testSuite  sN    
 	8&&'78E0023'%*FGr$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r     s     D Dt Dr$   c                    ^ RI Hp V P                  P                  V4      pV P	                  R\        VRR4      4       R# )zl
Check that if C{testSuite} and C{test_suite} are both present in a
module then C{testSuite} gets priority.
)mockcustomsuite3	testSuiter^   N)ru   rx  r6   r  rl   rm  )r7   rx  r   s   &  r"   test_loadModuleWithBothCustom)LoaderTests.test_loadModuleWithBothCustom  s5    
 	8&&'78geVT&BCr$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r     s     2 2T 2r$   c                    R R lp^ RI Hp WP                  uVn        p V P                  \        V P
                  P                  V4       W2n        R#   Y2n        i ; i)zb
Make sure that any C{AttributeError}s raised by C{testSuite} are not
swallowed by L{TestLoader}.
c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   ELoaderTests.test_customLoadRaisesAttributeError.<locals>.__annotate__  s     	7 	74 	7r$   c                     \        R 4      h)zshould be reraised)r=   r    r$   r"   ry  BLoaderTests.test_customLoadRaisesAttributeError.<locals>.testSuite  s     !566r$   rr  N)ru   rs  ry  r<   r=   r6   r  )r7   ry  rs  originals   &   r"   #test_customLoadRaisesAttributeError/LoaderTests.test_customLoadRaisesAttributeError  sO    	7 	809;U;U,"H	2ndkk.D.DFVW)1&&s   +A Ac               $    V ^8  d   QhRRRRRR/# )r   test1r   test2r   r/   r    )r!   s   "r"   r#   r     s(     	) 	)1	) 2	) 
		)r$   c                	    \        V4      p\        V4      pVP                  4        VP                  4        V P                  W44       R # r2   )r*   rN  rl   )r7   r  r  names1names2s   &&&  r"   assertSuitesEqualLoaderTests.assertSuitesEqual  s8    
 5!5!(r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r     s     / /4 /r$   c                    RpV P                   P                  W.R4      pV P                   P                  VR4      pV P                  W#4       R# )z0
Check that loadByNames ignores duplicate names
twisted.trial.test.test_logTN)r6   loadByNamesr   r  )r7   r\   suite1suite2s   &   r"   test_loadByNamesDuplicate%LoaderTests.test_loadByNamesDuplicate  sF     /((&)94@''5v.r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r     s     ? ? ?r$   c                    . ROpV P                   P                  V4      p\        P                  ! \	        V P                   P
                  V4      4      pV P                  \        V4      \        V4      4       R# )zH
L{TestLoader.loadByNames} preserves the order of tests provided to it.
N)$inheritancepackage.test_x.A.test_fooztwisted.trial.test.sampler}   r  z!twisted.trial.test.sample.FooTestpackage.test_module)r6   r  r   	TestSuitemapr   rl   r*   r7   r   r  r  s   &   r"   test_loadByNamesPreservesOrder*LoaderTests.test_loadByNamesPreservesOrder  sZ    
 ((1!!#dkk&<&<g"FG6*If,=>r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r     s     / / /r$   c                    RR.pV P                   P                  V4      p\        P                  ! \	        V P                   P
                  V4      4      pV P                  W#4       R# )z=
Check that loadByNames loads all the names that it is given
r}   r  Nr6   r  r   r  r  r   r  r  s   &   r"   test_loadDifferentNames#LoaderTests.test_loadDifferentNames  sR     !"78((1!!#dkk&<&<g"FGv.r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r     s     / /4 /r$   c                    RR.pV P                   P                  V4      p\        P                  ! \	        V P                   P
                  V4      4      pV P                  W#4       R# )z]
Check that test methods names which are inherited from are all
loaded rather than just one.
r  z$inheritancepackage.test_x.B.test_fooNr  )r7   methodsr  r  s   &   r"   test_loadInheritedMethods%LoaderTests.test_loadInheritedMethods  sV     32
 ((1!!#dkk&<&<g"FGv.r$   rT   N)%rU   rV   rW   rX   r   r4   r   r   r   r   r   r   r	  r  r  r  r   r$  r(  r/  r3  r7  r>  rB  rF  rP  rg  rn  rt  rz  r  r  r  r  r  r  rY   r    r$   r"   r   r      s    1T2E FI 
LN
5M4NF5
445N

0&	H	HD2$	)/? // /r$   r   c                  "    ] tR tRtR R ltRtR# )ZipLoadingTestsi"  c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   ZipLoadingTests.__annotate__#  s     9 9t 9r$   c                	   ^ RI Hp \        P                  V 4       V! V P                  V P                  R,           4       V ;P                  R,          un        V P                  V P                  V P                  .,           4       R# )r   )zipitz.zipN) twisted.python.test.test_zippathr  r   r4   r   r   r   )r7   r  s   & r"   r4   ZipLoadingTests.setUp#  sU    :$dkk4;;/0v4<<4;;-78r$   r    N)rU   rV   rW   rX   r4   rY   r    r$   r"   r  r  "  s    9 9r$   r  c                  l    ] tR tRtR R ltR R lt]P                  3R R lltR R	 lt	R
 R lt
RtR# )PackageOrderingTestsi,  c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   !PackageOrderingTests.__annotate__-  s     9 9t 9r$   c                	   \         P                  ! 4       V n        V P                  4       V n        \
        P                  P                  V P                  R 4      p\
        P                  ! V4       \        \
        P                  P                  VR4      R4      P                  4        \        P                  P                  W4       V P                  V P                  V P                  .,           4       R# )uberpackager   wbN)r   r5   r6   mktemptopDirr   rL   r   makedirsopencloser   r   r4   r   r   )r7   r   s   & r"   r4   PackageOrderingTests.setUp-  s    '')kkmdkk=9
FRWW\\&-0$7==?$$**484<<4;;-78r$   c                    V ^8  d   QhRRRR/# )r   r   zBCallable[[PythonModule | PythonAttribute], SupportsRichComparison]r   z5Generator[PythonModule | PythonAttribute, None, None]r    )r!   s   "r"   r#   r  6  s     +- +-X+-	>+-r$   c              #    "   \        R4      p. pVP                  4        FM  pVP                  P                  R4      R,          P	                  R4      '       g   K<  VP                  V4       KO  	  \        W1R7      pV EF  pVP                  R4      pVf   Vx  K  . pVP                  4        F@  p	\        P                  ! V	P                  4       4      '       g   K/  VP                  V	4       KB  	  \        WR7      p
V
 F|  p. pVP                  4        FM  pVP                  P                  R4      R,          P	                  R4      '       g   K<  VP                  V4       KO  	  \        WR7      pT Rj  xL
  K~  	  EK  	  R#  L5i)aF  
Right now, halfway by accident, trial sorts like this:

    1. all modules are grouped together in one list and sorted.

    2. within each module, the classes are grouped together in one list
       and sorted.

    3. finally within each class, each test method is grouped together
       in a list and sorted.

This attempts to return a sorted list of testable thingies following
those rules, so that we can compare the behavior of loadPackage.

The things that show as 'cases' are errors from modules which failed to
import, and test methods.  Let's gather all those together.
r  .test_)keyNr)   r   )r   walkModulesr^   split
startswithr&   sortedloaditerAttributesr   
isTestCase)r7   r   pkgtestModulesr   sortedModulesmodinfor\   testClassesattribsortedClassesclsinfotestMethodsattrsortedMethodss   &&             r"   _trialSortAlgorithm(PackageOrderingTests._trialSortAlgorithm6  s>    ( &//+J$$S)"-88AA"":. , {7$G\\$'F~ %446F((77#**62 7 !'{ ?,G"$K ' 6 6 899??3/3>>vFF'..t4 !9 %+;$CM,,,  - %" -s&   AFA>FA/F&F9F	:Fc                    V ^8  d   QhRRRR/# )r   r   z4Callable[[runner._Loadable], SupportsRichComparison]r   r/   r    )r!   s   "r"   r#   r  c  s     = =J=	=r$   c           
        ^ RI pWP                  n        V P                  P                  VRR7      p\        P
                  ! V\        4      p\        \        V4      4      p\        V P                  V4      4      p\        \        WT4      4       FT  w  pw  rxV P                  VP                  VP                  4       RWgP                  VP                  4       3,          4       KV  	  V P                  \        V4      \        V4      4       R# )z7
Verify that packages are loaded in the correct order.
NTr-  z#%d: %s != %s)r  r6   r   r  r   decorater   listr   r  	enumerater   rl   r^   r'   r   )	r7   r   r  r   resultingTestsmanifestnumbermanifestTest
actualTests	   &&       r"   loadSortedPackages'PackageOrderingTests.loadSortedPackagesc  s     	#''T'B !!%3mE2300892;)3
.F.\ !!6+<+<jmmo"NN3
 	XN(;<r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r  |  s     " "t "r$   c                	&    V P                  4        R # r2   r  r?   s   &r"   test_sortPackagesDefaultOrder2PackageOrderingTests.test_sortPackagesDefaultOrder|  s    !r$   c                   V ^8  d   QhRR/# r.   r    )r!   s   "r"   r#   r    s     
- 
-T 
-r$   c                	4    R  R lpV P                  V4       R# )c                    V ^8  d   QhRRRR/# )r   szrunner._Loadabler   rm   r    )r!   s   "r"   r#   FPackageOrderingTests.test_sortPackagesSillyOrder.<locals>.__annotate__  s     	 	+ 	 	r$   c                    \         P                  ! V 4      p\        VP                  R 4      4      P	                  4       pV# )r   )r   r^   r   r   	hexdigest)r  nds   &  r"   sillySorterEPackageOrderingTests.test_sortPackagesSillyOrder.<locals>.sillySorter  s2    
 AAAHHV$%//1AHr$   Nr  )r7   r  s   & r"   test_sortPackagesSillyOrder0PackageOrderingTests.test_sortPackagesSillyOrder  s    	 	,r$   )r6   r  N)rU   rV   rW   rX   r4   r  r   r^   r  r  r  rY   r    r$   r"   r  r  ,  s,    9+-\ NT[[=2"
- 
-r$   r  )5r   
__future__r   r   r   r   re  hashlibr   operatorr   typesr   typingr   r   r   hamcrestr	   r
   r   hamcrest.core.matcherr   twisted.pythonr   r   twisted.python.modulesr   r   r   twisted.python.reflectr   twisted.trialr   r   twisted.trial._asyncrunnerr   twisted.trial.itrialr   ru   r   matchersr   	_typeshedr   r*   r   r,   rd   rf   r   r  r  r    r$   r"   <module>r     s    # 	 
     5 5 : : ) ) K K 1 4 4 4 * ' 0!
X11 !
H50x,, xv}/(.. }/@
9k 9]-877 ]-r$   