U
    
W[                     @   s   d Z ddlmZmZ ddlZddlZddlmZ ddlm	Z	 erNddl
mZ ndd Zd	Zed
dZdZdZG dd de	jZG dd deZdS )zf
Classes and functions used by L{twisted.trial.test.test_util}
and L{twisted.trial.test.test_loader}.
    )divisionabsolute_importN)_PY3)unittest)invalidate_cachesc                   C   s   dS )zJ
        On python 2, import caches don't need to be invalidated.
        N r   r   r   =/usr/lib/python3/dist-packages/twisted/trial/test/packages.pyinvalidateImportCaches   s    r	   zv
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(object):
    def test_foo(self):
        pass


class AlphabetTest(unittest.SynchronousTestCase):
    def test_a(self):
        pass

    def test_b(self):
        pass

    def test_c(self):
        pass
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.
'''

from twisted.trial import unittest

class X(object):

    def test_foo(self):
        pass

class A(unittest.SynchronousTestCase, X):
    pass

class B(unittest.SynchronousTestCase, X):
    pass

c                   @   s   e Zd Zddddddddefd	d
efddefddefddefgZdd Zdd Z	dd Z
d!ddZdd Zd"ddZdd  ZdS )#PackageTest)zbadpackage/__init__.pyfrotz
)zbadpackage/test_module.py )zpackage2/__init__.pyr   )zpackage2/test_module.pyzimport frotz
)zpackage/__init__.pyr   )zpackage/frotz.pyr   )zpackage/test_bad_module.pyz%raise ZeroDivisionError("fake error")zpackage/test_dos_module.py)zpackage/test_import_module.pyzimport frotzzpackage/test_module.py)zgoodpackage/__init__.pyr   zgoodpackage/test_sample.py)zgoodpackage/sub/__init__.pyr   zgoodpackage/sub/test_sample.py)zinheritancepackage/__init__.pyr   zinheritancepackage/test_x.pyc                 C   s<   t j|d }|d}|d dkr2|d d }d|S )Nr   /__init__.)ospathsplitextsplitjoin)selffilenamenameZsegsr   r   r   _toModuleName{   s
    
zPackageTest._toModuleNamec                    s    fdd j D S )zQ
        Return matching module names for files listed in C{self.files}.
        c                    s   g | ]\}}  |qS r   )r   ).0r   coder   r   r   
<listcomp>   s     z*PackageTest.getModules.<locals>.<listcomp>)filesr   r   r   r   
getModules   s    zPackageTest.getModulesc              	   C   sH   |   }|  |  |D ]&}ztj|= W q tk
r@   Y qX qd S N)r    sortreversesysmodulesKeyError)r   r%   moduler   r   r   cleanUpModules   s    zPackageTest.cleanUpModulesr   c              
   C   sL   | j D ]@\}}tj||}| | t|d}|| W 5 Q R X qd S )Nw)r   r   r   r   _createDirectoryopenwrite)r   r   	parentDirr   contentsfdr   r   r   createFiles   s
    
zPackageTest.createFilesc                 C   s&   t j|}t j|s"t | d S r!   )r   r   dirnameexistsmakedirs)r   r   Z	directoryr   r   r   r*      s    zPackageTest._createDirectoryNc                 C   s.   t   |d kr|  }|| _| | j| d S r!   )r	   mktempparentr0   r   )r   r-   r   r   r   setUp   s
    zPackageTest.setUpc                 C   s   |    d S r!   )r(   r   r   r   r   tearDown   s    zPackageTest.tearDown)r   )N)__name__
__module____qualname__	dosModule
testModule
testSampletestInheritanceSampler   r   r    r(   r0   r*   r6   r7   r   r   r   r   r   e   s0   

r   c                   @   s&   e Zd ZdddZdd Zdd ZdS )	SysPathManglingTestNc                 C   s`   t   tjd d  | _tjd d  | _|d kr6|  }t| | | j| j	 | 
| j d S r!   )r	   r$   r   oldPathZnewPathr4   r   r6   appendr5   mangleSysPath)r   r5   r   r   r   r6      s    zSysPathManglingTest.setUpc                 C   s   t |  | | j d S r!   )r   r7   rB   r@   r   r   r   r   r7      s    
zSysPathManglingTest.tearDownc                 C   s   |t jd d < d S r!   )r$   r   )r   ZpathVarr   r   r   rB      s    z!SysPathManglingTest.mangleSysPath)N)r8   r9   r:   r6   r7   rB   r   r   r   r   r?      s   
r?   )__doc__Z
__future__r   r   r$   r   Ztwisted.python.compatr   Ztwisted.trialr   	importlibr   r	   r<   replacer;   r=   r>   ZSynchronousTestCaser   r?   r   r   r   r   <module>   s   )K