o b+@sjdZddlZddlZddlmZddlmZdZe ddZ dZ d Z Gd d d ej ZGd d d eZdS)zf Classes and functions used by L{twisted.trial.test.test_util} and L{twisted.trial.test.test_loader}. N)invalidate_caches)unittestzv from twisted.trial import unittest class FooTest(unittest.SynchronousTestCase): def testFoo(self): pass  z a '''This module is used by test_loader to test the Trial test loading functionality. Do NOT change the number of tests in this module. Do NOT change the names the tests in this module. ''' import unittest as pyunit from twisted.trial import unittest class FooTest(unittest.SynchronousTestCase): def test_foo(self): pass def test_bar(self): pass class PyunitTest(pyunit.TestCase): def test_foo(self): pass def test_bar(self): pass class NotATest: def test_foo(self): pass class AlphabetTest(unittest.SynchronousTestCase): def test_a(self): pass def test_b(self): pass def test_c(self): pass az '''This module is used by test_loader to test the Trial test loading functionality. Do NOT change the number of tests in this module. Do NOT change the names the tests in this module. ''' from twisted.trial import unittest class X: def test_foo(self): pass class A(unittest.SynchronousTestCase, X): pass class B(unittest.SynchronousTestCase, X): pass c@seZdZddddddddd d efd d efd defddefddefgZddZddZ ddZ d#ddZ ddZ d$dd Z d!d"ZdS)% PackageTest)zbadpackage/__init__.pyfrotz )zbadpackage/test_module.py)zunimportablepackage/__init__.pyr)z"unimportablepackage/test_module.pyzimport notarealmoduleok )zpackage2/__init__.pyr)zpackage2/test_module.pyz import frotz )zpackage/__init__.pyr)zpackage/frotz.pyr)zpackage/test_bad_module.pyz%raise ZeroDivisionError("fake error")zpackage/test_dos_module.py)zpackage/test_import_module.pyz import frotzzpackage/test_module.py)zgoodpackage/__init__.pyrzgoodpackage/test_sample.py)zgoodpackage/sub/__init__.pyrzgoodpackage/sub/test_sample.py)zinheritancepackage/__init__.pyrzinheritancepackage/test_x.pycCs<tj|d}|d}|ddkr|dd}d|S)Nr/__init__.)ospathsplitextsplitjoin)selffilenamenamesegsr=/usr/lib/python3/dist-packages/twisted/trial/test/packages.py _toModuleNamets     zPackageTest._toModuleNamecsfddjDS)zQ Return matching module names for files listed in C{self.files}. csg|] \}}|qSr)r).0rcoderrr sz*PackageTest.getModules..)filesrrrr getModules{szPackageTest.getModulesc CsD|}|||D]}ztj|=WqtyYqwdSN)rsortreversesysmodulesKeyError)rr"modulerrrcleanUpModuless  zPackageTest.cleanUpModulesr c Cs`|jD]*\}}tj||}||t|d }||Wdn1s(wYqdS)Nw)rr r r_createDirectoryopenwrite)rr parentDirrcontentsfdrrr createFiless   zPackageTest.createFilescCs*tj|}tj|st|dSdSr)r r dirnameexistsmakedirs)rr directoryrrrr's  zPackageTest._createDirectoryNcCs.t|dur |}||_||j|dSr)invalidateImportCachesmktempparentr-r)rr*rrrsetUps zPackageTest.setUpcCs |dSr)r%rrrrtearDowns zPackageTest.tearDown)r r)__name__ __module__ __qualname__ dosModule testModule testSampletestInheritanceSamplerrrr%r-r'r5r6rrrrr^s6   rc@s&eZdZdddZddZddZdS) SysPathManglingTestNcCs`ttjdd|_tjdd|_|dur|}t|||j|j | |jdSr) r2r!r oldPathnewPathr3rr5appendr4 mangleSysPath)rr4rrrr5s zSysPathManglingTest.setUpcCst|||jdSr)rr6rBr?rrrrr6s zSysPathManglingTest.tearDowncCs|tjdd<dSr)r!r )rpathVarrrrrBsz!SysPathManglingTest.mangleSysPathr)r7r8r9r5r6rBrrrrr>s  r>)__doc__r r! importlibrr2 twisted.trialrr;replacer:r<r=SynchronousTestCaserr>rrrrs   )D