ó
Ð#…Mc           @   sZ  d  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	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ d e	 j f d „  ƒ  YZ d Z d „  Z d „  Z d e	 j f d „  ƒ  YZ d e	 j f d „  ƒ  YZ d e	 j f d „  ƒ  YZ d S(   s"   
Tests for Twisted plugin system.
iÿÿÿÿN(   t	   Interface(   t   unittest(   t   textFromEventDictt   addObservert   removeObserver(   t   FilePath(   t   mergeFunctionMetadata(   t   plugint   ITestPluginc           B   s   e  Z d  Z RS(   sS   
    A plugin for use by the plugin system's unit tests.

    Do not use this.
    (   t   __name__t
   __module__t   __doc__(    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyR      s   t   ITestPlugin2c           B   s   e  Z d  Z RS(   s   
    See L{ITestPlugin}.
    (   R	   R
   R   (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyR       s   t   PluginTestCasec           B   sÚ   e  Z d  Z d „  Z d „  Z e d „ Z d „  Z d „  Z d „  Z	 e e	 ƒ Z	 d „  Z
 e e
 ƒ Z
 d „  Z e e ƒ Z d	 „  Z e e ƒ Z d
 „  Z e e ƒ Z d „  Z e e ƒ Z d „  Z e e ƒ Z d „  Z RS(   s_   
    Tests which verify the behavior of the current, active Twisted plugins
    directory.
    c         C   sß   t  j |  _ t  j j ƒ  |  _ t |  j ƒ  ƒ |  _ |  j j	 ƒ  |  j j
 d ƒ |  _ |  j j	 ƒ  |  j j
 d ƒ j d ƒ t t ƒ j d ƒ j |  j j
 d ƒ ƒ d |  _ t  j j d |  j j ƒ d d	 l } | |  _ d	 S(
   sV   
        Save C{sys.path} and C{sys.modules}, and create a package for tests.
        t	   mypackages   __init__.pyt    s   plugin_basic.pys   testplugin.pyt
   testplugini    iÿÿÿÿN(   t   syst   patht   originalPatht   modulest   copyt   savedModulesR   t   mktempt   roott   createDirectoryt   childt   packaget
   setContentt   __file__t   siblingt   copyTot   originalPlugint   insertR   t   module(   t   selfR   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   setUp-   s    	c         C   s1   |  j  t j (t j j ƒ  t j j |  j ƒ d S(   sR   
        Restore C{sys.path} and C{sys.modules} to their original values.
        N(   R   R   R   R   t   cleart   updateR   (   R#   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   tearDownD   s    c         C   sÄ   | j  j d ƒ } d j | d  ƒ } | d } t t j | | ƒ t j | j  =xm d d g | rk d g pn g  D]L } y t j | j | ƒ Wqp t	 k
 r» } | j
 t
 j k r¼ ‚  q¼ qp Xqp Wd  S(   Nt   .iÿÿÿÿt   ct   oR   (   R	   t   splitt   joint   delattrR   R   t   ost   removeR   t   OSErrort   errnot   ENOENT(   R#   R"   t   deleteSourcet
   modulePatht   packageNamet
   moduleNamet   extt   ose(    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   _unimportPythonModuleM   s    
&c         C   s   |  j  j d ƒ j ƒ  d S(   s;   
        Remove the plugins B{droping.cache} file.
        s   dropin.cacheN(   R   R   R/   (   R#   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   _clearCache\   s    c            s   ‡  f d †  } t  ˆ  | ƒ S(   sþ   
        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.
        c            s6   ˆ  |  ƒ ˆ  |  ƒ |  j  ƒ  ˆ  |  ƒ ˆ  |  ƒ d  S(   N(   R:   (   R#   (   t   meth(    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   wrappedj   s
    



(   R   (   R;   R<   (    (   R;   s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   _withCachenessc   s    c         C   s/  t  j |  j ƒ } | |  j } |  j | j d |  j f ƒ |  j d | j ƒ g  | j D] } t	 | j
 k rY | ^ qY d } |  j | j | ƒ |  j | j d ƒ |  j | j j ƒ  d ƒ |  j | j
 t	 t  j g ƒ | j ƒ  } |  j | t j d |  j f j ƒ d d l j } |  j | | j ƒ d S(   s	  
        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.
        s   mypackage.%ss   I'm a test drop-in.i    t
   TestPlugins*   A plugin used solely for testing purposes.iÿÿÿÿN(   R   t   getCacheR"   R    t   assertEqualsR6   t   assertInt   descriptiont   pluginsR   t   providedt   assertIdenticalt   dropint   namet   stript   IPlugint   loadR   R   R>   t   mypackage.testpluginR   (   R#   t   cacheRF   t   pt   p1t
   realPlugint   tp(    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt
   test_caches   s$    /c         C   sl   t  t j t |  j ƒ ƒ } |  j t | ƒ d ƒ d d g } x( | D]  } | j | j ƒ | j	 ƒ  qD Wd S(   s  
        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.
        i   t   AnotherTestPlugint   ThirdTestPluginN(
   t   listR   t
   getPluginsR   R"   R@   t   lenR/   R	   t   test(   R#   RC   t   namesRM   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   test_plugins™   s    c         C   sæ   t  t ƒ j d ƒ j |  j j d ƒ ƒ zŸ |  j d t j ƒ |  j	 t
 t j d d ƒ d ƒ t t j t |  j ƒ ƒ } |  j t | ƒ d ƒ d d	 g } x( | D]  } | j | j ƒ | j ƒ  q¢ WWd
 |  j t j d t ƒ Xd
 S(   se   
        Check that L{plugin.getPlugins} is able to detect plugins added at
        runtime.
        s   plugin_extra1.pys   pluginextra.pys   mypackage.pluginextraR   t   pluginextras&   mypackage still has pluginextra modulei   R>   t   FourthTestPluginN(   R   R   R   R   R   R   t   failIfInR   R   t   failIft   hasattrRT   R   RU   R   R"   R@   RV   R/   R	   t   test1R9   t   True(   R#   t   plgsRX   RM   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   test_detectNewFiles¬   s    
c         C   s#  t  t ƒ j d ƒ j |  j j d ƒ ƒ zÜ t t j t	 |  j
 ƒ ƒ } |  j t | ƒ d ƒ t  t ƒ j d ƒ j |  j j d ƒ ƒ |  j t j d ƒ t t j t	 |  j
 ƒ ƒ } |  j t | ƒ d ƒ d d d	 g } x( | D]  } | j | j ƒ | j ƒ  qß WWd
 |  j t j d t ƒ Xd
 S(   s…   
        Check that if the content of a plugin change, L{plugin.getPlugins} is
        able to detect the new plugins added.
        s   plugin_extra1.pys   pluginextra.pyi   s   plugin_extra2.pys   mypackage.pluginextrai   R>   R[   t   FifthTestPluginN(   R   R   R   R   R   R   RT   R   RU   R   R"   R@   RV   R9   R   R   R/   R	   R_   R`   (   R#   Ra   RX   RM   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   test_detectFilesChangedË   s"    
c         C   s•   t  t ƒ j d ƒ j |  j j d ƒ ƒ z t t j t	 |  j
 ƒ ƒ Wd |  j t j d t ƒ Xt t j t	 |  j
 ƒ ƒ } |  j d t | ƒ ƒ d S(   ss   
        Check that when a dropin file is removed, L{plugin.getPlugins} doesn't
        return it anymore.
        s   plugin_extra1.pys   pluginextra.pyNs   mypackage.pluginextrai   (   R   R   R   R   R   R   RT   R   RU   R   R"   R9   R   R   R`   R@   RV   (   R#   Ra   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   test_detectFilesRemovedî   s    
c         C   sˆ   |  j  ƒ  } |  j t j j | ƒ ƒ |  j j j | ƒ z5 t t	 j
 t |  j ƒ ƒ } |  j t | ƒ d ƒ Wd |  j j j | ƒ Xd S(   sy   
        Test that getCache skips over any entries in a plugin package's
        C{__path__} which do not exist.
        i   N(   R   R]   R.   R   t   existsR"   t   __path__t   appendRT   R   RU   R   t   assertEqualRV   R/   (   R#   R   Ra   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   test_nonexistentPathEntry  s    c         C   s¤   t  |  j ƒ  ƒ } |  j | j ƒ  ƒ | j ƒ  | j d ƒ j } |  j j j	 | ƒ z5 t
 t j t |  j ƒ ƒ } |  j t | ƒ d ƒ Wd |  j j j | ƒ Xd S(   s¡   
        Test that getCache skips over any entries in a plugin package's
        C{__path__} which refer to children of paths which are not directories.
        t   test_packagei   N(   R   R   R]   Rf   t   touchR   R   R"   Rg   Rh   RT   R   RU   R   Ri   RV   R/   (   R#   R   R   Ra   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   test_nonDirectoryChildEntry  s    
c         C   sX  t  j |  j ƒ |  j j d ƒ } t t ƒ j d ƒ j |  j j d ƒ ƒ t	 j
 |  j j d ƒ t	 j
 | j d ƒ |  j t	 j
 |  j j d ƒ |  j t	 j
 | j d ƒ g  } t | j ƒ |  j t | j ƒ t  j |  j ƒ } |  j d | ƒ |  j |  j | ƒ d | j t j f } x8 | D] } | t | ƒ k r Pq q W|  j d	 | f ƒ d
 S(   s¿   
        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.
        s   dropin.caches   plugin_extra1.pys   pluginextra.pyi@  i   iÀ  RZ   s3   Unable to write to plugin cache %s: error number %ds;   Did not observe unwriteable cache warning in log events: %rN(   R   R?   R"   R   R   R   R   R   R   R.   t   chmodR   t
   addCleanupR   Rh   R   RA   R    R1   t   EPERMR   t   fail(   R#   t	   cachepatht   eventsRL   t   expectedt   event(    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   test_deployedMode(  s,    (   R	   R
   R   R$   R'   t   FalseR9   R:   R=   RQ   RY   Rb   Rd   Re   Rj   Rm   Rv   (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyR   '   s*   						#			 			sj   
from twisted.plugin import pluginPackagePaths
__path__.extend(pluginPackagePaths(__name__))
__all__ = []
c         C   s   d |  f S(   Ns¸   from zope.interface import classProvides
from twisted.plugin import IPlugin
from twisted.test.test_plugin import ITestPlugin

class %s(object):
    classProvides(IPlugin, ITestPlugin)
(    (   RG   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   pluginFileContents[  s    c         C   s˜   |  j  ƒ  |  j d ƒ } | j  ƒ  | rB | j d ƒ j d ƒ n  | j d ƒ } | j  ƒ  | rz | j d ƒ j t ƒ n  | j | d ƒ j | ƒ | S(   s'   
    Create a plugindummy package.
    t   plugindummys   __init__.pyR   RC   s   .py(   R   R   R   t   pluginInitFile(   t	   entrypatht   pluginContentt   realt   pluginModulet   pkgt   plugs(    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   _createPluginDummye  s    


t   DeveloperSetupTestsc           B   sh   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z RS(   s³   
    These tests verify things about the plugin system without actually
    interacting with the deployed 'twisted.plugins' package, instead creating a
    temporary package.
    c         C   sÁ  t  j |  _ t  j j ƒ  |  _ t |  j ƒ  ƒ |  _ |  j j	 ƒ  |  j j
 d ƒ |  _ |  j j
 d ƒ |  _ |  j j
 d ƒ |  _ t |  j t d ƒ t d ƒ |  _ t |  j t d ƒ t d ƒ |  _ t |  j t d ƒ t d ƒ |  _ t  j j g  |  j |  j g D] } | j ^ qÿ ƒ |  j ƒ  |  j j
 d	 ƒ j
 d
 ƒ |  _ |  j j
 d ƒ |  _ t j ƒ  } t j |  j j
 d ƒ j | d f d ƒ t j |  j j | d f d ƒ |  j ƒ  |  j ƒ  d S(   s7  
        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.
        t   system_patht   development_patht   application_patht   systemt   plugindummy_builtint   devt   appt   plugindummy_appRy   RC   s   dropin.caches   plugindummy_builtin.pyiˆ  i   iÐ  N(   R   R   t	   savedPathR   R   R   R   R   t   fakeRootR   R   t
   systemPatht   devPatht   appPathR   Rx   R`   t   systemPackaget
   devPackageRw   t
   appPackaget   extendt   getAllPluginst   sysplugt   syscachet   timeR.   t   utimet
   lockSystemt   resetEnvironment(   R#   t   xt   now(    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyR$   ~  s8     
!
c         C   s0   t  j |  j j d ƒ t  j |  j j d ƒ d S(   sW   
        Lock the system directories, as if they were unwritable by this user.
        im  N(   R.   Rn   R•   R   R–   (   R#   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyR™   ¬  s    c         C   s0   t  j |  j j d ƒ t  j |  j j d ƒ d S(   sW   
        Unlock the system directories, as if they were writable by this user.
        iÿ  N(   R.   Rn   R•   R   R–   (   R#   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   unlockSystem´  s    c         C   sA   d d l  } t t j t | j ƒ ƒ } g  | D] } | j ^ q. S(   sl   
        Get all the plugins loadable from our dummy package, and return their
        short names.
        iÿÿÿÿN(   t   plugindummy.pluginsRT   R   RU   R   RC   R	   (   R#   Ry   R›   t   plug(    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyR”   ¼  s    c         C   sF   |  j  ƒ  t j j g  |  j |  j |  j g D] } | j ^ q, ƒ d S(   sc   
        Change the environment to what it should be just as the test is
        starting.
        N(   t   unsetEnvironmentR   R   R“   RŽ   R   R   (   R#   R›   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyRš   È  s    
c         C   s1   t  j j ƒ  t  j j |  j ƒ |  j t  j (d S(   sh   
        Change the Python environment back to what it was before the test was
        started.
        N(   R   R   R%   R&   R   R‹   R   (   R#   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyR    Ò  s    c         C   s   |  j  ƒ  |  j ƒ  d S(   sÑ   
        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#   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyR'   Ü  s    
c         C   sG   x@ t  d ƒ D]2 } |  j ƒ  } | j ƒ  |  j | d d g ƒ q Wd S(   s  
        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.
        i   R‰   Rˆ   N(   t   rangeR”   t   sortRi   (   R#   R›   RX   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt"   test_developmentPluginAvailabilityê  s    	
c         C   s  |  j  j d ƒ } | j t d ƒ ƒ t j ƒ  d } t j | j | | f ƒ | j d ƒ } t	 j
 |  j  j d d ƒt j | j | | f ƒ | j ƒ  |  j ƒ  |  j d |  j ƒ  ƒ |  j d |  j ƒ  ƒ |  j ƒ  | j t d ƒ ƒ |  j d |  j ƒ  ƒ |  j d |  j ƒ  ƒ d S(	   sÜ   
        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.
        s   stale.pyt   oneiè  s	   stale.pyct   quieti   t   twoN(   R’   R   R   Rx   R—   R.   R˜   R   R   t
   compileallt   compile_dirR/   Rš   RA   R”   R\   (   R#   t   mypathR›   t   pyc(    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   test_freshPyReplacesStalePycù  s    


c         C   sÝ   |  j  ƒ  |  j j d ƒ j t d ƒ ƒ |  j ƒ  t j j |  j	 j ƒ g  } t
 | j ƒ |  j t | j ƒ |  j d |  j ƒ  ƒ d |  j j t j f } x8 | D] } | t | ƒ k r¥ Pq¥ q¥ W|  j d | f ƒ d S(   sF  
        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".
        s   newstuff.pyR¤   s3   Unable to write to plugin cache %s: error number %ds;   Did not observe unwriteable cache warning in log events: %rN(   R   R•   R   R   Rx   R™   R   R   R/   RŽ   R   Rh   Ro   R   RA   R”   R–   R1   Rp   R   Rq   (   R#   Rs   Rt   Ru   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   test_newPluginsOnReadOnlyPath  s     	

(   R	   R
   R   R$   R™   R   R”   Rš   R    R'   R£   R«   R¬   (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyR‚   w  s   	.				
	
			t   AdjacentPackageTestsc           B   s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s–   
    Tests for the behavior of the plugin system when there are multiple
    installed copies of the package containing the plugins being loaded.
    c         C   s#   t  j |  _ t  j j ƒ  |  _ d S(   sS   
        Save the elements of C{sys.path} and the items of C{sys.modules}.
        N(   R   R   R   R   R   R   (   R#   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyR$   @  s    c         C   s1   |  j  t j (t j j ƒ  t j j |  j ƒ d S(   sR   
        Restore C{sys.path} and C{sys.modules} to their original values.
        N(   R   R   R   R   R%   R&   R   (   R#   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyR'   H  s    c         C   s—   | j  | ƒ } | j  d ƒ } | j ƒ  | j  d ƒ j d ƒ | j  d ƒ } | j ƒ  | j  d ƒ j t ƒ | j  | d ƒ } | j t | ƒ ƒ | S(   s`  
        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.
        t   dummys   __init__.pyR   RC   s   .py(   R   t   makedirsR   Rz   Rx   (   R#   R   RG   t
   pluginNamet	   directoryR   RC   R~   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   createDummyPackageQ  s    

c         C   sÀ   t  |  j ƒ  ƒ } | j ƒ  |  j | d d ƒ } |  j | d d ƒ } t j j | j ƒ t j j | j ƒ d d l } t t	 j
 t | j ƒ ƒ } |  j d g g  | D] } | j ^ q¦ ƒ d S(   sê   
        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.
        t   firstt
   someplugint   secondiÿÿÿÿN(   R   R   R¯   R²   R   R   Rh   t   dummy.pluginsRT   R   RU   R   RC   Ri   R	   (   R#   R   t   firstDirectoryt   secondDirectoryR®   RC   RM   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt.   test_hiddenPackageSamePluginModuleNameObscuredq  s    
c         C   sÀ   t  |  j ƒ  ƒ } | j ƒ  |  j | d d ƒ } |  j | d d ƒ } t j j | j ƒ t j j | j ƒ d d l } t t	 j
 t | j ƒ ƒ } |  j d g g  | D] } | j ^ q¦ ƒ d S(   sè   
        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³   t
   thispluginRµ   t
   thatpluginiÿÿÿÿN(   R   R   R¯   R²   R   R   Rh   R¶   RT   R   RU   R   RC   Ri   R	   (   R#   R   R·   R¸   R®   RC   RM   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt3   test_hiddenPackageDifferentPluginModuleNameObscured†  s    
(   R	   R
   R   R$   R'   R²   R¹   R¼   (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyR­   :  s   				 	t   PackagePathTestsc           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   sg   
    Tests for L{plugin.pluginPackagePaths} which constructs search paths for
    plugin packages.
    c         C   s   t  j |  _ d S(   s3   
        Save the elements of C{sys.path}.
        N(   R   R   R   (   R#   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyR$   ¢  s    c         C   s   |  j  t j (d S(   s<   
        Restore C{sys.path} to its original value.
        N(   R   R   R   (   R#   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyR'   ©  s    c         C   sz   t  d ƒ } t  d ƒ } | j | j g t _ |  j t j d ƒ | j d ƒ j d ƒ j | j d ƒ j d ƒ j g ƒ d S(   s®   
        L{plugin.pluginPackagePaths} should return a list containing each
        directory in C{sys.path} with a suffix based on the supplied package
        name.
        t   foot   bars   dummy.pluginsR®   RC   N(   R   R   R   Ri   R   t   pluginPackagePathsR   (   R#   R¾   R¿   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   test_pluginDirectories°  s    c         C   s¸   t  |  j ƒ  ƒ } | j d ƒ j d ƒ j d ƒ } | j ƒ  | j d ƒ j d ƒ | j d ƒ j | j d ƒ j g t _ |  j t j	 d ƒ | j d ƒ j d ƒ j d ƒ j g ƒ d S(	   s™  
        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®   RC   s   __init__.pyR   R¿   s   dummy.pluginsN(
   R   R   R   R¯   R   R   R   Ri   R   RÀ   (   R#   R   R¾   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   test_pluginPackagesExcluded¿  s    	!
'(   R	   R
   R   R$   R'   RÁ   RÂ   (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyR½   œ  s
   			(   R   R   R1   R.   R—   R§   t   zope.interfaceR    t   twisted.trialR   t   twisted.python.logR   R   R   t   twisted.python.filepathR   t   twisted.python.utilR   t   twistedR   R   R   t   TestCaseR   Rz   Rx   R   R‚   R­   R½   (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_plugin.pyt   <module>   s$   0	ÿ 3	
	Ãb