o
    Óó·ih  ã                   @  sP  d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	m
Z ddlmZ ddlmZmZmZ ddlmZ ddlmZ dd	lmZ dd
lmZmZmZmZ ddlmZ edƒZG dd„ deƒZ G dd„ deƒZ!G dd„ dej"ƒZ#dZ$d*dd„Z%d+d d!„Z&G d"d#„ d#eƒZ'G d$d%„ d%ej"ƒZ(G d&d'„ d'ej"ƒZ)G d(d)„ d)ej"ƒZ*dS ),z"
Tests for Twisted plugin system.
é    )ÚannotationsN)Úinvalidate_caches)Ú
ModuleType)ÚCallableÚ	TypedDictÚTypeVar)Ú	Interface)Úplugin)ÚFilePath)Ú	EventDictÚaddObserverÚremoveObserverÚtextFromEventDict)ÚunittestÚ_Tc                   @  ó   e Zd ZdZdS )ÚITestPluginzS
    A plugin for use by the plugin system's unit tests.

    Do not use this.
    N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   ú^C:\Users\psant\Downloads\PAF backend\school\venv\Lib\site-packages\twisted/test/test_plugin.pyr      ó    r   c                   @  r   )ÚITestPlugin2z
    See L{ITestPlugin}.
    Nr   r   r   r   r   r   &   r   r   c                   @  s¼   e Zd ZdZd)dd„Zd)dd„Z	d*d+dd„Zd)dd„Zd,dd„Zed)dd„ƒZ	d)dd„Z
ed)dd„ƒZed)dd„ƒZed)dd„ƒZed)d d!„ƒZed)d"d#„ƒZed)d$d%„ƒZd)d&d'„Zd(S )-ÚPluginTestsz_
    Tests which verify the behavior of the current, active Twisted plugins
    directory.
    ÚreturnÚNonec                 C  s¤   t jdd… | _t j ¡ | _t|  ¡ ƒ| _| j 	¡  | j 
d¡| _| j 	¡  | j 
d¡ d¡ ttƒ d¡ | j 
d¡¡ d| _t j d| jj¡ ddl}|| _dS )	zV
        Save C{sys.path} and C{sys.modules}, and create a package for tests.
        NÚ	mypackageú__init__.pyó    zplugin_basic.pyztestplugin.pyÚ
testpluginr   )ÚsysÚpathÚoriginalPathÚmodulesÚcopyÚsavedModulesr
   ÚmktempÚrootÚcreateDirectoryÚchildÚpackageÚ
setContentÚ__file__ÚsiblingÚcopyToÚoriginalPluginÚinsertr   Úmodule)Úselfr   r   r   r   ÚsetUp2   s   


ÿ
zPluginTests.setUpc                 C  ó,   | j tjdd…< tj ¡  tj | j¡ dS ©zR
        Restore C{sys.path} and C{sys.modules} to their original values.
        N©r%   r#   r$   r&   ÚclearÚupdater(   ©r5   r   r   r   ÚtearDownJ   ó   
zPluginTests.tearDownFr4   r   ÚdeleteSourceÚboolc              	   C  s”   |j d usJ ‚|j d¡}d |d d… ¡}|d }ttj| |ƒ tj|j= ddg|r/dgp0g  D ]}z
t |j | ¡ W q2 t	yG   Y q2w d S )NÚ.éÿÿÿÿÚcÚoÚ )
r/   r   ÚsplitÚjoinÚdelattrr#   r&   ÚosÚremoveÚFileNotFoundError)r5   r4   r?   Z
modulePathÚpackageNameÚ
moduleNameÚextr   r   r   Ú_unimportPythonModuleR   s   
ÿýz!PluginTests._unimportPythonModulec                 C  s   | j  d¡ ¡  dS )z;
        Remove the plugins B{droping.cache} file.
        údropin.cacheN)r-   r,   rJ   r<   r   r   r   Ú_clearCacheb   ó   zPluginTests._clearCacheÚmethúCallable[[PluginTests], object]úCallable[[PluginTests], None]c                   s   t  ˆ ¡d‡ fdd„ƒ}|S )	zþ
        This is a paranoid test wrapper, that calls C{meth} 2 times, clear the
        cache, and calls it 2 other times. It's supposed to ensure that the
        plugin system behaves correctly no matter what the state of the cache
        is.
        r5   r   r   r   c                   s,   ˆ | ƒ ˆ | ƒ |   ¡  ˆ | ƒ ˆ | ƒ d S )N)rQ   r<   ©rS   r   r   Úwrappedr   s
   z+PluginTests._withCacheness.<locals>.wrappedN)r5   r   r   r   )Ú	functoolsÚwraps)rS   rW   r   rV   r   Ú_withCachenessh   s   
zPluginTests._withCachenessc                 C  sÒ   t  | j¡}|| j }|  |jd| j› �¡ |  d|j¡ dd„ |jD ƒd }|  	|j
|¡ |  |jd¡ |  |j ¡ d¡ |  |jtt jg¡ | ¡ }|  	|tjd| j› � j¡ ddlm} |  	||j¡ dS )	a	  
        Check that the cache returned by L{plugin.getCache} hold the plugin
        B{testplugin}, and that this plugin has the properties we expect:
        provide L{TestPlugin}, has the good name and description, and can be
        loaded successfully.
        z
mypackage.zI'm a test drop-in.c                 S  s   g | ]	}t |jv r|‘qS r   )r   Úprovided©Ú.0Úpr   r   r   Ú
<listcomp>‹   s    z*PluginTests.test_cache.<locals>.<listcomp>r   Ú
TestPluginz*A plugin used solely for testing purposes.N)r	   ÚgetCacher4   r2   ÚassertEqualrM   ÚassertInÚdescriptionÚpluginsZassertIsÚdropinÚnameÚstripr[   r   ZIPluginÚloadr#   r&   r`   Zmypackage.testpluginr"   )r5   Úcacherf   Úp1Z
realPluginÚtpr   r   r   Ú
test_cache|   s$   

ÿþzPluginTests.test_cachec                 C  s>   t  | j¡| j }tdd„ |jD ƒƒd }|  t|ƒd¡ dS )zm
        L{CachedPlugin} has a helpful C{repr} which contains relevant
        information about it.
        c                 s  s   � | ]
}|j d kr|V  qdS )r`   N©rg   r\   r   r   r   Ú	<genexpr>§   s   € z-PluginTests.test_cacheRepr.<locals>.<genexpr>r   zT<CachedPlugin 'TestPlugin'/'mypackage.testplugin' (provides 'ITestPlugin, IPlugin')>N)r	   ra   r4   r2   Úlistre   rb   Úrepr)r5   ZcachedDropinZcachedPluginr   r   r   Útest_cacheRepr¡   s   ÿþzPluginTests.test_cacheReprc                 C  sL   t t t| j¡ƒ}|  t|ƒd¡ ddg}|D ]}| |j¡ | 	¡  qdS )a  
        L{plugin.getPlugins} should return the list of plugins matching the
        specified interface (here, L{ITestPlugin2}), and these plugins
        should be instances of classes with a C{test} method, to be sure
        L{plugin.getPlugins} load classes correctly.
        é   ZAnotherTestPluginZThirdTestPluginN)
rp   r	   Ú
getPluginsr   r4   rb   ÚlenrJ   r   Útest)r5   re   Únamesr^   r   r   r   Útest_plugins°   s   
þzPluginTests.test_pluginsc              
   C  s¸   t tƒ d¡ | j d¡¡ zC|  dtj¡ |  	t
tjd dƒd¡ tt t| j¡ƒ}|  t|ƒd¡ dd	g}|D ]}| |j¡ | ¡  q9W |  tjd d
¡ dS |  tjd d
¡ w )ze
        Check that L{plugin.getPlugins} is able to detect plugins added at
        runtime.
        úplugin_extra1.pyúpluginextra.pyúmypackage.pluginextrar   Úpluginextraz&mypackage still has pluginextra modulers   r`   ÚFourthTestPluginTN)r
   r/   r0   r1   r-   r,   ÚfailIfInr#   r&   ÚassertFalseÚhasattrrp   r	   rt   r   r4   rb   ru   rJ   r   Útest1rO   ©r5   Úplgsrw   r^   r   r   r   Útest_detectNewFilesÁ   s"   
ÿþ
þ*zPluginTests.test_detectNewFilesc              
   C  sà   t tƒ d¡ | j d¡¡ zWtt t	| j
¡ƒ}|  t|ƒd¡ t tƒ d¡ | j d¡¡ |  tjd ¡ tt t	| j
¡ƒ}|  t|ƒd¡ g d¢}|D ]}| |j¡ | ¡  qMW |  tjd d¡ d	S |  tjd d¡ w )
z…
        Check that if the content of a plugin change, L{plugin.getPlugins} is
        able to detect the new plugins added.
        ry   rz   rs   zplugin_extra2.pyr{   é   )r`   r}   ZFifthTestPluginTN)r
   r/   r0   r1   r-   r,   rp   r	   rt   r   r4   rb   ru   rO   r#   r&   rJ   r   r�   r‚   r   r   r   Útest_detectFilesChangedß   s$   
ÿ
ÿ
þ*z#PluginTests.test_detectFilesChangedc              
   C  s€   t tƒ d¡ | j d¡¡ ztt t	| j
¡ƒ W |  tjd d¡ n
|  tjd d¡ w tt t	| j
¡ƒ}|  dt|ƒ¡ dS )zs
        Check that when a dropin file is removed, L{plugin.getPlugins} doesn't
        return it anymore.
        ry   rz   r{   Té   N)r
   r/   r0   r1   r-   r,   rp   r	   rt   r   r4   rO   r#   r&   rb   ru   )r5   rƒ   r   r   r   Útest_detectFilesRemoved   s   
ÿ(z#PluginTests.test_detectFilesRemovedc              	   C  sp   |   ¡ }|  tj |¡¡ | jj |¡ ztt	 
t| j¡ƒ}|  t|ƒd¡ W | jj |¡ dS | jj |¡ w )zy
        Test that getCache skips over any entries in a plugin package's
        C{__path__} which do not exist.
        r‡   N)r)   r   rI   r$   Úexistsr4   Ú__path__Úappendrp   r	   rt   r   rb   ru   rJ   )r5   r$   rƒ   r   r   r   Útest_nonexistentPathEntry  s   "z%PluginTests.test_nonexistentPathEntryc              	   C  s„   t |  ¡ ƒ}|  | ¡ ¡ | ¡  | d¡j}| jj 	|¡ zt
t t| j¡ƒ}|  t|ƒd¡ W | jj |¡ dS | jj |¡ w )z¡
        Test that getCache skips over any entries in a plugin package's
        C{__path__} which refer to children of paths which are not directories.
        Ztest_packager‡   N)r
   r)   r   r‰   Útouchr,   r$   r4   rŠ   r‹   rp   r	   rt   r   rb   ru   rJ   )r5   r$   r,   rƒ   r   r   r   Útest_nonDirectoryChildEntry"  s   "z'PluginTests.test_nonDirectoryChildEntryc                 C  s  t  | j¡ | j d¡}ttƒ d¡ | j d¡¡ t	ƒ  t
 | jjd¡ t
 |jd¡ |  t
j| jjd¡ |  t
j|jd¡ g }t|jƒ |  t|j¡ t  | j¡}|  d|¡ |  | j|¡ d|jtjf }|D ]}t|ƒ}|d	usvJ ‚||v r} d	S qj|  d
|f ¡ d	S )z¿
        The C{dropin.cache} file may not be writable: the cache should still be
        attainable, but an error should be logged to show that the cache
        couldn't be updated.
        rP   ry   rz   i@  é   iÀ  r|   ú3Unable to write to plugin cache %s: error number %dNú;Did not observe unwriteable cache warning in log events: %r)r	   ra   r4   r-   r,   r
   r/   r0   r1   ÚinvalidateImportCachesrI   Úchmodr$   Ú
addCleanupr   r‹   r   rc   r2   ÚerrnoÚEPERMr   Úfail)r5   Z	cachepathÚeventsrj   ÚexpectedÚeventÚ	maybeTextr   r   r   Útest_deployedMode3  s>   
ÿ
þÿÿÿzPluginTests.test_deployedModeN©r   r   )F)r4   r   r?   r@   r   r   )rS   rT   r   rU   )r   r   r   r   r6   r=   rO   rQ   rZ   rm   rr   rx   r„   r†   rˆ   rŒ   rŽ   rœ   r   r   r   r   r   ,   s0    

	ÿ


$ r   sj   
from twisted.plugin import pluginPackagePaths
__path__.extend(pluginPackagePaths(__name__))
__all__ = []
rg   Ústrr   Úbytesc                 C  s   d  | ¡ d¡S )Nz¬from zope.interface import provider
from twisted.plugin import IPlugin
from twisted.test.test_plugin import ITestPlugin

@provider(IPlugin, ITestPlugin)
class {}:
    pass
Úascii)ÚformatÚencodern   r   r   r   ÚpluginFileContentsm  s   õr£   Ú	entrypathúFilePath[str]ÚpluginContentÚrealr@   ÚpluginModulec                 C  sl   |   ¡  |  d¡}|  ¡  |r| d¡ d¡ | d¡}|  ¡  |r*| d¡ t¡ | |d ¡ |¡ |S )z'
    Create a plugindummy package.
    Úplugindummyr    r!   re   ú.pyN)r+   r,   r.   ÚpluginInitFile)r¤   r¦   r§   r¨   ÚpkgZplugsr   r   r   Ú_createPluginDummy}  s   

r­   c                   @  s   e Zd ZU ded< dS )Ú_HasBoolLegacyKeyr@   ÚlegacyN)r   r   r   Ú__annotations__r   r   r   r   r®   �  s   
 r®   c                   @  st   e Zd ZdZddd„Zddd„Zddd	„Zddd„Zddd„Zddd„Z	ddd„Z
ddd„Zddd„Zddd„ZdS )ÚDeveloperSetupTestsz³
    These tests verify things about the plugin system without actually
    interacting with the deployed 'twisted.plugins' package, instead creating a
    temporary package.
    r   r   c                 C  s>  t jdd… | _t j ¡ | _t|  ¡ ƒ| _| j 	¡  | j 
d¡| _| j 
d¡| _| j 
d¡| _t| jtdƒddƒ| _t| jtdƒddƒ| _t| jtd	ƒd
dƒ| _t j dd„ | j| jfD ƒ¡ |  ¡  | j 
d¡ 
d¡| _| j 
d¡| _t ¡ }t | j 
d¡j|d fd ¡ t | jj|d fd ¡ |  ¡  |  ¡  dS )a7  
        Create a complex environment with multiple entries on sys.path, akin to
        a developer's environment who has a development (trunk) checkout of
        Twisted, a system installed version of Twisted (for their operating
        system's tools) and a project which provides Twisted plugins.
        NZsystem_pathZdevelopment_pathZapplication_pathÚsystemTZplugindummy_builtinÚdevÚappFZplugindummy_appc                 S  ó   g | ]}|j ‘qS r   ©r$   ©r]   Úxr   r   r   r_   ´  ó    z-DeveloperSetupTests.setUp.<locals>.<listcomp>r©   re   rP   zplugindummy_builtin.pyiˆ  rs   iÐ  )r#   r$   Ú	savedPathr&   r'   r(   r
   r)   ZfakeRootr+   r,   Ú
systemPathÚdevPathÚappPathr­   r£   ZsystemPackageZ
devPackageÚ
appPackageÚextendÚgetAllPluginsÚsysplugÚsyscacheÚtimerI   ÚutimeÚ
lockSystemÚresetEnvironment)r5   Únowr   r   r   r6   ›  s2   
ÿÿÿ zDeveloperSetupTests.setUpc                 C  ó$   t  | jjd¡ t  | jjd¡ dS )zW
        Lock the system directories, as if they were unwritable by this user.
        im  N©rI   r“   rÁ   r$   rÂ   r<   r   r   r   rÅ   Å  ó   zDeveloperSetupTests.lockSystemc                 C  rÈ   )zW
        Unlock the system directories, as if they were writable by this user.
        iÿ  NrÉ   r<   r   r   r   ÚunlockSystemÌ  rÊ   z DeveloperSetupTests.unlockSystemú	list[str]c                 C  s(   ddl }tt t|j¡ƒ}dd„ |D ƒS )zl
        Get all the plugins loadable from our dummy package, and return their
        short names.
        r   Nc                 S  rµ   r   ©r   )r]   Zplugr   r   r   r_   Ý  r¹   z5DeveloperSetupTests.getAllPlugins.<locals>.<listcomp>)Zplugindummy.pluginsrp   r	   rt   r   re   )r5   r©   r¸   r   r   r   rÀ   Ó  s   z!DeveloperSetupTests.getAllPluginsc                 C  s.   |   ¡  tj dd„ | j| j| jfD ƒ¡ dS )zc
        Change the environment to what it should be just as the test is
        starting.
        c                 S  rµ   r   r¶   r·   r   r   r   r_   å  r¹   z8DeveloperSetupTests.resetEnvironment.<locals>.<listcomp>N)ÚunsetEnvironmentr#   r$   r¿   r¼   r»   r½   r<   r   r   r   rÆ   ß  s   &z$DeveloperSetupTests.resetEnvironmentc                 C  s2   t ƒ  tj ¡  tj | j¡ | jtjdd…< dS )zh
        Change the Python environment back to what it was before the test was
        started.
        N)r’   r#   r&   r:   r;   r(   rº   r$   r<   r   r   r   rÎ   ç  s   
z$DeveloperSetupTests.unsetEnvironmentc                 C  s   |   ¡  |  ¡  dS )zÑ
        Reset the Python environment to what it was before this test ran, and
        restore permissions on files which were marked read-only so that the
        directory may be cleanly cleaned up.
        N)rÎ   rË   r<   r   r   r   r=   ñ  s   zDeveloperSetupTests.tearDownc                 C  s2   t dƒD ]}|  ¡ }| ¡  |  |ddg¡ qdS )a  
        Plugins added in the development path should be loadable, even when
        the (now non-importable) system path contains its own idea of the
        list of plugins for a package.  Inversely, plugins added in the
        system path should not be available.
        r…   r´   r³   N)ÚrangerÀ   Úsortrb   )r5   r¸   rw   r   r   r   Ú"test_developmentPluginAvailabilityþ  s
   	ýz6DeveloperSetupTests.test_developmentPluginAvailabilityc                 C  sâ   | j  d¡}| tdƒ¡ t ¡ d }t |j||f¡ | d¡}t	dd�}t
j| j jfddi|¤Ž t |j||f¡ | ¡  |  ¡  |  d|  ¡ ¡ |  d	|  ¡ ¡ |  ¡  | td	ƒ¡ |  d|  ¡ ¡ |  d	|  ¡ ¡ d
S )zÜ
        Verify that if a stale .pyc file on the PYTHONPATH is replaced by a
        fresh .py file, the plugins in the new .py are picked up rather than
        the stale .pyc, even if the .pyc is still around.
        zstale.pyÚoneiè  z	stale.pycT)r¯   Úquietr‡   ZtwoN)r¾   r,   r.   r£   rÃ   rI   rÄ   r$   r0   r®   Ú
compileallÚcompile_dirrJ   rÆ   rc   rÀ   r~   )r5   Zmypathr¸   ZpycÚextrar   r   r   Útest_freshPyReplacesStalePyc  s    

z0DeveloperSetupTests.test_freshPyReplacesStalePycc                 C  s´   |   ¡  | j d¡ tdƒ¡ |  ¡  tj | j	j¡ g }t
|jƒ |  t|j¡ |  d|  ¡ ¡ d| jjtjf }|D ]}t|ƒ}|dusHJ ‚||v rO dS q<|  d|f ¡ dS )aF  
        Verify that a failure to write the dropin.cache file on a read-only
        path will not affect the list of plugins returned.

        Note: this test should pass on both Linux and Windows, but may not
        provide useful coverage on Windows due to the different meaning of
        "read-only directory".
        znewstuff.pyrÒ   r�   Nr‘   )rË   rÁ   r,   r.   r£   rÅ   r#   r$   rJ   r¼   r   r‹   r”   r   rc   rÀ   rÂ   r•   r–   r   r—   )r5   r˜   r™   rš   r›   r   r   r   Útest_newPluginsOnReadOnlyPath,  s.   	
þÿÿÿz1DeveloperSetupTests.test_newPluginsOnReadOnlyPathNr�   )r   rÌ   )r   r   r   r   r6   rÅ   rË   rÀ   rÆ   rÎ   r=   rÑ   r×   rØ   r   r   r   r   r±   ”  s    

*







 r±   c                   @  sB   e Zd ZdZddd„Zddd„Zddd„Zddd„Zddd„ZdS )ÚAdjacentPackageTestsz–
    Tests for the behavior of the plugin system when there are multiple
    installed copies of the package containing the plugins being loaded.
    r   r   c                 C  s    t jdd… | _t j ¡ | _dS )zS
        Save the elements of C{sys.path} and the items of C{sys.modules}.
        N)r#   r$   r%   r&   r'   r(   r<   r   r   r   r6   [  s   zAdjacentPackageTests.setUpc                 C  r7   r8   r9   r<   r   r   r   r=   b  r>   zAdjacentPackageTests.tearDownr*   r¥   rg   rž   Ú
pluginNamec                 C  sn   |  |¡}|  d¡}| ¡  |  d¡ d¡ |  d¡}| ¡  |  d¡ t¡ |  |d ¡}| t|ƒ¡ |S )a`  
        Create a directory containing a Python package named I{dummy} with a
        I{plugins} subpackage.

        @type root: L{FilePath}
        @param root: The directory in which to create the hierarchy.

        @type name: C{str}
        @param name: The name of the directory to create which will contain
            the package.

        @type pluginName: C{str}
        @param pluginName: The name of a module to create in the
            I{dummy.plugins} package.

        @rtype: L{FilePath}
        @return: The directory which was created to contain the I{dummy}
            package.
        Údummyr    r!   re   rª   N)r,   Úmakedirsr.   r«   r£   )r5   r*   rg   rÚ   Ú	directoryr-   re   r¨   r   r   r   ÚcreateDummyPackagej  s   


z'AdjacentPackageTests.createDummyPackagec                 C  s‚   t |  ¡ ƒ}| ¡  |  |dd¡}|  |dd¡}tj |j¡ tj |j¡ ddl}tt	 
t|j¡ƒ}|  dgdd„ |D ƒ¡ dS )zê
        Only plugins from the first package in sys.path should be returned by
        getPlugins in the case where there are two Python packages by the same
        name installed, each with a plugin module by a single name.
        ÚfirstZ
somepluginÚsecondr   Nc                 S  rµ   r   rÍ   r\   r   r   r   r_   �  r¹   zWAdjacentPackageTests.test_hiddenPackageSamePluginModuleNameObscured.<locals>.<listcomp>©r
   r)   rÜ   rÞ   r#   r$   r‹   Zdummy.pluginsrp   r	   rt   r   re   rb   ©r5   r*   ZfirstDirectoryZsecondDirectoryrÛ   re   r   r   r   Ú.test_hiddenPackageSamePluginModuleNameObscured‹  ó   zCAdjacentPackageTests.test_hiddenPackageSamePluginModuleNameObscuredc                 C  s‚   t |  ¡ ƒ}| ¡  |  |dd¡}|  |dd¡}tj |j¡ tj |j¡ ddl}tt	 
t|j¡ƒ}|  dgdd„ |D ƒ¡ dS )	zè
        Plugins from the first package in sys.path should be returned by
        getPlugins in the case where there are two Python packages by the same
        name installed, each with a plugin module by a different name.
        rß   Z
thispluginrà   Z
thatpluginr   Nc                 S  rµ   r   rÍ   r\   r   r   r   r_   ±  r¹   z\AdjacentPackageTests.test_hiddenPackageDifferentPluginModuleNameObscured.<locals>.<listcomp>rá   râ   r   r   r   Ú3test_hiddenPackageDifferentPluginModuleNameObscuredŸ  rä   zHAdjacentPackageTests.test_hiddenPackageDifferentPluginModuleNameObscuredNr�   )r*   r¥   rg   rž   rÚ   rž   r   r¥   )	r   r   r   r   r6   r=   rÞ   rã   rå   r   r   r   r   rÙ   U  s    



!rÙ   c                   @  s8   e Zd ZdZddd„Zddd„Zddd	„Zdd
d„ZdS )ÚPackagePathTestszg
    Tests for L{plugin.pluginPackagePaths} which constructs search paths for
    plugin packages.
    r   r   c                 C  s   t jdd… | _dS )z3
        Save the elements of C{sys.path}.
        N)r#   r$   r%   r<   r   r   r   r6   º  rR   zPackagePathTests.setUpc                 C  s   | j tjdd…< dS )z<
        Restore C{sys.path} to its original value.
        N)r%   r#   r$   r<   r   r   r   r=   À  rR   zPackagePathTests.tearDownc                 C  sT   t dƒ}t dƒ}|j|jgt_|  t d¡| d¡ d¡j| d¡ d¡jg¡ dS )z®
        L{plugin.pluginPackagePaths} should return a list containing each
        directory in C{sys.path} with a suffix based on the supplied package
        name.
        ÚfooÚbarúdummy.pluginsrÛ   re   N)r
   r$   r#   rb   r	   ÚpluginPackagePathsr,   )r5   rç   rè   r   r   r   Útest_pluginDirectoriesÆ  s   þþz'PackagePathTests.test_pluginDirectoriesc                 C  s€   t |  ¡ ƒ}| d¡ d¡ d¡}| ¡  | d¡ d¡ | d¡j| d¡jgt_|  t 	d¡| d¡ d¡ d¡jg¡ dS )	a™  
        L{plugin.pluginPackagePaths} should exclude directories which are
        Python packages.  The only allowed plugin package (the only one
        associated with a I{dummy} package which Python will allow to be
        imported) will already be known to the caller of
        L{plugin.pluginPackagePaths} and will most commonly already be in
        the C{__path__} they are about to mutate.
        rç   rÛ   re   r    r!   rè   ré   N)
r
   r)   r,   rÜ   r.   r$   r#   rb   r	   rê   )r5   r*   rç   r   r   r   Útest_pluginPackagesExcluded×  s   	þz,PackagePathTests.test_pluginPackagesExcludedNr�   )r   r   r   r   r6   r=   rë   rì   r   r   r   r   ræ   ´  s    


ræ   )rg   rž   r   rŸ   )
r¤   r¥   r¦   rŸ   r§   r@   r¨   rž   r   r¥   )+r   Ú
__future__r   rÔ   r•   rX   rI   r#   rÃ   Ú	importlibr   r’   Útypesr   Útypingr   r   r   Zzope.interfacer   Ztwistedr	   Ztwisted.python.filepathr
   Ztwisted.python.logr   r   r   r   Ztwisted.trialr   r   r   r   ZTestCaser   r«   r£   r­   r®   r±   rÙ   ræ   r   r   r   r   Ú<module>   s<     <

 B_