§
    Ètºfh  ã                  óÐ  — 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e¦  «        Z  G d„ de¦  «        Z! G d„ dej"        ¦  «        Z#dZ$d(d„Z%d)d„Z& G d „ d!e¦  «        Z' G d"„ d#ej"        ¦  «        Z( G d$„ d%ej"        ¦  «        Z) G 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__© ó    úW/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/test/test_plugin.pyr   r      s   € € € € € ðð ð ð r   r   c                  ó   — e Zd ZdZdS )ÚITestPlugin2z
    See L{ITestPlugin}.
    Nr   r   r   r   r   r   &   s   € € € € € ðð ð ð r   r   c                  óö   — e Zd ZdZdd„Zdd„Z	 ddd„Zdd„Zdd„Zedd„¦   «         Z	dd„Z
edd„¦   «         Zedd„¦   «         Zedd„¦   «         Zedd„¦   «         Zedd„¦   «         Zedd„¦   «         Zdd„ZdS )ÚPluginTestsz_
    Tests which verify the behavior of the current, active Twisted plugins
    directory.
    ÚreturnÚNonec                óâ  — 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__.pyr   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#   s     r   ÚsetUpzPluginTests.setUp2   s!  € õ  œH Q Q QœKˆÔÝœK×,Ò,Ñ.Ô.ˆÔå˜TŸ[š[™]œ]Ñ+Ô+ˆŒ	ØŒ	×!Ò!Ñ#Ô#Ð#Ø”y—’ {Ñ3Ô3ˆŒØŒ×$Ò$Ñ&Ô&Ð&ØŒ×Ò˜=Ñ)Ô)×4Ò4°SÑ9Ô9Ð9å•ÑÔ×"Ò"Ð#4Ñ5Ô5×<Ò<ØŒL×Ò˜Ñ/Ô/ñ	
ô 	
ð 	
ð +ˆÔåŒ�Š˜˜4œ9œ>Ñ*Ô*Ð*ØÐÐÐàˆŒˆˆr   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+   ©r8   s    r   ÚtearDownzPluginTests.tearDownJ   óI   € ð Ô'�Œ���‰ÝŒ×ÒÑÔÐÝŒ×Ò˜4Ô,Ñ-Ô-Ð-Ð-Ð-r   Fr7   r   ÚdeleteSourceÚboolc                ór  — |j         €J ‚|j                             d¦  «        }d                     |d d…         ¦  «        }|d         }t	          t
          j        |         |¦  «         t
          j        |j        = ddg|rdgpg z   D ]/}	 t          j        |j         |z   ¦  «         Œ # t          $ r Y Œ,w xY wd S )Nú.éÿÿÿÿÚcÚoÚ )
r2   r   ÚsplitÚjoinÚdelattrr&   r)   ÚosÚremoveÚFileNotFoundError)r8   r7   rB   Ú
modulePathÚpackageNameÚ
moduleNameÚexts          r   Ú_unimportPythonModulez!PluginTests._unimportPythonModuleR   sÙ   € ð ŒÐ*Ð*Ð*Ø”_×*Ò*¨3Ñ/Ô/ˆ
Ø—h’h˜z¨#¨2¨#œÑ/Ô/ˆØ ”^ˆ
å•”˜KÔ(¨*Ñ5Ô5Ð5ÝŒK˜œÐ(Ø˜�: Ð!6°2°$Ð!<¸"Ñ=ð 	ð 	ˆCðÝ”	˜&œ/¨CÑ/Ñ0Ô0Ð0Ð0øÝ$ð ð ð Ø�ðøøøð	ð 	s   Â
B'Â'
B4Â3B4c                ó^   — | j                              d¦  «                             ¦   «          dS )z;
        Remove the plugins B{droping.cache} file.
        údropin.cacheN)r0   r/   rN   r?   s    r   Ú_clearCachezPluginTests._clearCacheb   s,   € ð 	Œ×Ò˜>Ñ*Ô*×1Ò1Ñ3Ô3Ð3Ð3Ð3r   ÚmethúCallable[[PluginTests], object]úCallable[[PluginTests], None]c                óH   ‡ — t          j        ‰ ¦  «        dˆ f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.
        r8   r   r    r!   c                óˆ   •—  ‰| ¦  «          ‰| ¦  «         |                       ¦   «           ‰| ¦  «          ‰| ¦  «         d S )N)rW   )r8   rX   s    €r   Úwrappedz+PluginTests._withCacheness.<locals>.wrappedr   sM   ø€ àˆD�‰JŒJˆJØˆD�‰JŒJˆJØ×ÒÑÔÐØˆD�‰JŒJˆJØˆD�‰JŒJˆJˆJˆJr   )r8   r   r    r!   )Ú	functoolsÚwraps)rX   r]   s   ` r   Ú_withCachenesszPluginTests._withCachenessh   s?   ø€ õ 
Œ˜Ñ	Ô	ð	ð 	ð 	ð 	ð 	ñ 
Ô	ð	ð ˆr   c                óê  — t          j        | j        ¦  «        }|| j                 }|                      |j        d| j        › �¦  «         |                      d|j        ¦  «         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                ó.   — g | ]}t           |j        v ¯|‘ŒS r   )r   Úprovided©Ú.0Úps     r   ú
<listcomp>z*PluginTests.test_cache.<locals>.<listcomp>‹   s$   € ÐEÐEÐE�A­;¸!¼*Ð+DÐ+DˆaÐ+DÐ+DÐ+Dr   r   Ú
TestPluginz*A plugin used solely for testing purposes.N)r
   ÚgetCacher7   r5   ÚassertEqualrR   ÚassertInÚdescriptionÚpluginsÚassertIsÚdropinÚnameÚstriprc   r   ÚIPluginÚloadr&   r)   rh   Úmypackage.testpluginr%   )r8   Úcachero   Úp1Ú
realPluginÚtps         r   Ú
test_cachezPluginTests.test_cache|   sh  € õ ” ¤Ñ,Ô,ˆà�tÔ*Ô+ˆØ×Ò˜Ô*Ð,N¸Ô9LÐ,NÐ,NÑOÔOÐOØ�ŠÐ+¨VÔ-?Ñ@Ô@Ð@ð FÐE˜œÐEÑEÔEÀaÔHˆØ�Š�b”i Ñ(Ô(Ð(Ø×Ò˜œ ,Ñ/Ô/Ð/ð 	×ÒØŒN× Ò Ñ"Ô"Ð$Pñ	
ô 	
ð 	
ð 	×Ò˜œ¥{µF´NÐ&CÑDÔDÐDØ—W’W‘Y”Yˆ
à�ŠØÝŒKÐ: TÔ%8Ð:Ð:Ô;ÔFñ	
ô 	
ð 	
ð 	*Ð)Ð)Ð)Ð)Ð)à�Š�j "¤-Ñ0Ô0Ð0Ð0Ð0r   c                óÜ   — t          j        | j        ¦  «        | j                 }t	          d„ |j        D ¦   «         ¦  «        d         }|                      t          |¦  «        d¦  «         dS )zm
        L{CachedPlugin} has a helpful C{repr} which contains relevant
        information about it.
        c              3  ó0   K  — | ]}|j         d k    ¯|V — ŒdS )rh   N©rp   rd   s     r   ú	<genexpr>z-PluginTests.test_cacheRepr.<locals>.<genexpr>§   s.   è è € ÐVÐV !¸q¼vÈÒ?UÐ?U˜AÐ?UÐ?UÐ?UÐ?UÐVÐVr   r   zT<CachedPlugin 'TestPlugin'/'mypackage.testplugin' (provides 'ITestPlugin, IPlugin')>N)r
   ri   r7   r5   Úlistrm   rj   Úrepr)r8   ÚcachedDropinÚcachedPlugins      r   Útest_cacheReprzPluginTests.test_cacheRepr¡   sx   € õ
 ” t¤{Ñ3Ô3°DÔ4GÔHˆÝÐVÐV |Ô';ÐVÑVÔVÑVÔVØô
ˆð 	×ÒÝ�ÑÔð1ñ	
ô 	
ð 	
ð 	
ð 	
r   c                ó  — t          t          j        t          | j        ¦  «        ¦  «        }|                      t          |¦  «        d¦  «         ddg}|D ]0}|                     |j        ¦  «         | 	                    ¦   «          Œ1d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.
        é   ÚAnotherTestPluginÚThirdTestPluginN)
r~   r
   Ú
getPluginsr   r7   rj   ÚlenrN   r   Útest)r8   rm   Únamesrf   s       r   Útest_pluginszPluginTests.test_plugins°   sƒ   € õ •vÔ(­°t´{ÑCÔCÑDÔDˆà×Ò�˜W™œ qÑ)Ô)Ð)à$Ð&7Ð8ˆØð 	ð 	ˆAØ�LŠL˜œÑ$Ô$Ð$Ø�FŠF‰HŒHˆHˆHð	ð 	r   c                ó  — t          t          ¦  «                             d¦  «                             | j                             d¦  «        ¦  «         	 |                      dt          j        ¦  «         |  	                    t          t          j        d         d¦  «        d¦  «         t          t          j        t          | j        ¦  «        ¦  «        }|                      t#          |¦  «        d¦  «         dd	g}|D ]0}|                     |j        ¦  «         |                     ¦   «          Œ1	 |                      t          j        d         d
¦  «         dS # |                      t          j        d         d
¦  «         w xY 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 moduler„   rh   ÚFourthTestPluginTN)r   r2   r3   r4   r0   r/   ÚfailIfInr&   r)   ÚassertFalseÚhasattrr~   r
   r‡   r   r7   rj   rˆ   rN   r   Útest1rT   ©r8   ÚplgsrŠ   rf   s       r   Útest_detectNewFileszPluginTests.test_detectNewFilesÁ   s[  € õ 	•ÑÔ×"Ò"Ð#5Ñ6Ô6×=Ò=ØŒL×ÒÐ/Ñ0Ô0ñ	
ô 	
ð 	
ð	Sà�MŠMÐ1µ3´;Ñ?Ô?Ð?Ø×ÒÝ�œ KÔ0°-Ñ@Ô@Ø8ñô ð õ
 �Ô)­+°t´{ÑCÔCÑDÔDˆDð ×Ò�S ™YœY¨Ñ*Ô*Ð*à!Ð#5Ð6ˆEØð ð �Ø—’˜QœZÑ(Ô(Ð(Ø—’‘	”	�	�	ðð ×&Ò&¥s¤{Ð3JÔ'KÈTÑRÔRÐRÐRÐRøˆD×&Ò&¥s¤{Ð3JÔ'KÈTÑRÔRÐRÐRøøøs   ÁCE Å(E?c                óè  — t          t          ¦  «                             d¦  «                             | j                             d¦  «        ¦  «         	 t          t          j        t          | j
        ¦  «        ¦  «        }|                      t          |¦  «        d¦  «         t          t          ¦  «                             d¦  «                             | j                             d¦  «        ¦  «         |                      t          j        d         ¦  «         t          t          j        t          | j
        ¦  «        ¦  «        }|                      t          |¦  «        d¦  «         g d¢}|D ]0}|                     |j        ¦  «         |                     ¦   «          Œ1	 |                      t          j        d         d¦  «         d	S # |                      t          j        d         d¦  «         w xY w)
z…
        Check that if the content of a plugin change, L{plugin.getPlugins} is
        able to detect the new plugins added.
        r�   rŽ   r„   zplugin_extra2.pyr�   é   )rh   r‘   ÚFifthTestPluginTN)r   r2   r3   r4   r0   r/   r~   r
   r‡   r   r7   rj   rˆ   rT   r&   r)   rN   r   r•   r–   s       r   Útest_detectFilesChangedz#PluginTests.test_detectFilesChangedß   s¬  € õ 	•ÑÔ×"Ò"Ð#5Ñ6Ô6×=Ò=ØŒL×ÒÐ/Ñ0Ô0ñ	
ô 	
ð 	
ð	SÝ�Ô)­+°t´{ÑCÔCÑDÔDˆDà×Ò�S ™YœY¨Ñ*Ô*Ð*å•XÑÔ×&Ò&Ð'9Ñ:Ô:×AÒAØ”×"Ò"Ð#3Ñ4Ô4ñô ð ð
 ×&Ò&¥s¤{Ð3JÔ'KÑLÔLÐLõ �Ô)­+°t´{ÑCÔCÑDÔDˆDà×Ò�S ™YœY¨Ñ*Ô*Ð*àIÐIÐIˆEØð ð �Ø—’˜QœZÑ(Ô(Ð(Ø—’‘	”	�	�	ðð ×&Ò&¥s¤{Ð3JÔ'KÈTÑRÔRÐRÐRÐRøˆD×&Ò&¥s¤{Ð3JÔ'KÈTÑRÔRÐRÐRøøøs   ÁEG	 Ç	(G1c                óF  — t          t          ¦  «                             d¦  «                             | j                             d¦  «        ¦  «         	 t          t          j        t          | j
        ¦  «        ¦  «         |                      t          j        d         d¦  «         n+# |                      t          j        d         d¦  «         w xY wt          t          j        t          | j
        ¦  «        ¦  «        }|                      dt          |¦  «        ¦  «         dS )zs
        Check that when a dropin file is removed, L{plugin.getPlugins} doesn't
        return it anymore.
        r�   rŽ   r�   Té   N)r   r2   r3   r4   r0   r/   r~   r
   r‡   r   r7   rT   r&   r)   rj   rˆ   )r8   r—   s     r   Útest_detectFilesRemovedz#PluginTests.test_detectFilesRemoved   sï   € õ 	•ÑÔ×"Ò"Ð#5Ñ6Ô6×=Ò=ØŒL×ÒÐ/Ñ0Ô0ñ	
ô 	
ð 	
ð	Så•Ô"¥;°´Ñ<Ô<Ñ=Ô=Ð=ð ×&Ò&¥s¤{Ð3JÔ'KÈTÑRÔRÐRÐRøˆD×&Ò&¥s¤{Ð3JÔ'KÈTÑRÔRÐRÐRøøøÝ•FÔ%¥k°4´;Ñ?Ô?Ñ@Ô@ˆØ×Ò˜�C ™IœIÑ&Ô&Ð&Ð&Ð&s   Á,B' Â'(Cc                óö  — |                       ¦   «         }|                      t          j                             |¦  «        ¦  «         | j        j                             |¦  «         	 t          t          j
        t          | j        ¦  «        ¦  «        }|                      t          |¦  «        d¦  «         | j        j                             |¦  «         dS # | j        j                             |¦  «         w xY w)zy
        Test that getCache skips over any entries in a plugin package's
        C{__path__} which do not exist.
        rž   N)r,   r“   rM   r'   Úexistsr7   Ú__path__Úappendr~   r
   r‡   r   rj   rˆ   rN   )r8   r'   r—   s      r   Útest_nonexistentPathEntryz%PluginTests.test_nonexistentPathEntry  sÇ   € ð �{Š{‰}Œ}ˆØ×Ò�œŸš¨Ñ-Ô-Ñ.Ô.Ð.àŒÔ×#Ò# DÑ)Ô)Ð)ð	.Ý�Ô)­+°t´{ÑCÔCÑDÔDˆDØ×Ò�S ™YœY¨Ñ*Ô*Ð*àŒKÔ ×'Ò'¨Ñ-Ô-Ð-Ð-Ð-øˆDŒKÔ ×'Ò'¨Ñ-Ô-Ð-Ð-øøøs   Á'AC Ã!C8c                óV  — t          |                      ¦   «         ¦  «        }|                      |                     ¦   «         ¦  «         |                     ¦   «          |                     d¦  «        j        }| j        j         	                    |¦  «         	 t          t          j        t          | j        ¦  «        ¦  «        }|                      t          |¦  «        d¦  «         | j        j                             |¦  «         dS # | j        j                             |¦  «         w xY 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.
        Útest_packagerž   N)r   r,   r“   r¡   Útouchr/   r'   r7   r¢   r£   r~   r
   r‡   r   rj   rˆ   rN   )r8   r'   r/   r—   s       r   Útest_nonDirectoryChildEntryz'PluginTests.test_nonDirectoryChildEntry"  sê   € õ ˜Ÿš™œÑ&Ô&ˆØ×Ò˜Ÿš™œÑ'Ô'Ð'Ø�
Š
‰ŒˆØ—
’
˜>Ñ*Ô*Ô/ˆØŒÔ×#Ò# EÑ*Ô*Ð*ð	/Ý�Ô)­+°t´{ÑCÔCÑDÔDˆDØ×Ò�S ™YœY¨Ñ*Ô*Ð*àŒKÔ ×'Ò'¨Ñ.Ô.Ð.Ð.Ð.øˆDŒKÔ ×'Ò'¨Ñ.Ô.Ð.Ð.øøøs   ÂAD Ä!D(c                óÚ  — t          j        | j        ¦  «         | j                             d¦  «        }t          t          ¦  «                             d¦  «                             | j                             d¦  «        ¦  «         t          ¦   «          t          j        | j        j        d¦  «         t          j        |j        d¦  «         |                      t          j        | j        j        d¦  «         |                      t          j        |j        d¦  «         g }t          |j        ¦  «         |                      t           |j        ¦  «         t          j        | j        ¦  «        }|                      d|¦  «         |                      | j        |¦  «         d|j        t&          j        fz  }|D ]}t+          |¦  «        }|€J ‚||v r d	S Œ|                      d
|›�¦  «         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.
        rV   r�   rŽ   i@  é   iÀ  r�   ú3Unable to write to plugin cache %s: error number %dNú9Did not observe unwriteable cache warning in log events: )r
   ri   r7   r0   r/   r   r2   r3   r4   ÚinvalidateImportCachesrM   Úchmodr'   Ú
addCleanupr   r£   r   rk   r5   ÚerrnoÚEPERMr   Úfail)r8   Ú	cachepathÚeventsru   ÚexpectedÚeventÚ	maybeTexts          r   Útest_deployedModezPluginTests.test_deployedMode3  sÕ  € õ 	Œ˜œÑ$Ô$Ð$à”L×&Ò& ~Ñ6Ô6ˆ	õ 	•ÑÔ×"Ò"Ð#5Ñ6Ô6×=Ò=ØŒL×ÒÐ/Ñ0Ô0ñ	
ô 	
ð 	
õ 	Ñ Ô Ð å
Œ�”Ô" EÑ*Ô*Ð*å
Œ�” Ñ'Ô'Ð'Ø�Š�œ $¤,Ô"3°UÑ;Ô;Ð;Ø�Š�œ )¤.°%Ñ8Ô8Ð8ð #%ˆÝ�F”MÑ"Ô"Ð"Ø�Š�¨¬Ñ6Ô6Ð6å” ¤Ñ,Ô,ˆà�Š�m UÑ+Ô+Ð+Ø�Š�dÔ)¨5Ñ1Ô1Ð1ð IØŒNÝŒKðL
ñ 
ˆð ð 		ð 		ˆEÝ)¨%Ñ0Ô0ˆIØÐ(Ð(Ð(Ø˜9Ð$Ð$Ø��ð %ð �IŠIˆIà & ð)ñô ð ð ð r   N©r    r!   )F)r7   r   rB   rC   r    r!   )rX   rY   r    rZ   )r   r   r   r   r9   r@   rT   rW   r`   ry   r‚   r‹   r˜   rœ   rŸ   r¤   r¨   r¸   r   r   r   r   r   ,   sž  € € € € € ðð ð
 ð  ð  ð  ð0.ð .ð .ð .ð 8=ðð ð ð ð ð 4ð 4ð 4ð 4ðð ð ð ð( ð"1ð "1ð "1ñ „^ð"1ðH
ð 
ð 
ð 
ð ðð ð ñ „^ðð  ðSð Sð Sñ „^ðSð: ðSð Sð Sñ „^ðSð@ ð'ð 'ð 'ñ „^ð'ð" ð.ð .ð .ñ „^ð.ð ð/ð /ð /ñ „^ð/ð /ð /ð /ð /ð /ð /r   r   sj   
from twisted.plugin import pluginPackagePaths
__path__.extend(pluginPackagePaths(__name__))
__all__ = []
rp   Ústrr    Úbytesc                óR   — 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Úencoder|   s    r   ÚpluginFileContentsrÀ   m  s$   € ð÷ 
Š�‰Œß	Š�‰Œðr   Ú	entrypathúFilePath[str]ÚpluginContentÚrealrC   ÚpluginModulec                óÚ  — |                       ¦   «          |                      d¦  «        }|                      ¦   «          |r(|                     d¦  «                             d¦  «         |                     d¦  «        }|                      ¦   «          |r-|                     d¦  «                             t          ¦  «         |                     |dz   ¦  «                             |¦  «         |S )z'
    Create a plugindummy package.
    Úplugindummyr$   r   rm   ú.py)r.   r/   r1   ÚpluginInitFile)rÁ   rÃ   rÄ   rÅ   ÚpkgÚplugss         r   Ú_createPluginDummyrÌ   }  sÖ   € ð ×ÒÑÔÐØ
�/Š/˜-Ñ
(Ô
(€CØ×ÒÑÔÐØð 1Ø�	Š	�-Ñ Ô ×+Ò+¨CÑ0Ô0Ð0Ø�IŠI�iÑ Ô €EØ	×ÒÑÔÐØð >Ø�Š�MÑ"Ô"×-Ò-­nÑ=Ô=Ð=Ø	‡K‚K�˜uÑ$Ñ%Ô%×0Ò0°Ñ?Ô?Ð?Ø€Lr   c                  ó   — e Zd ZU ded<   dS )Ú_HasBoolLegacyKeyrC   ÚlegacyN)r   r   r   Ú__annotations__r   r   r   rÎ   rÎ   �  s   € € € € € € Ø€L€L�L€L€Lr   rÎ   c                  ób   — e Zd ZdZdd„Zdd„Zdd„Zdd„Zdd	„Zdd
„Z	dd„Z
dd„Zdd„Z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                ó  — 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„ | j        | j        fD ¦   «         ¦  «         |                      ¦   «          | j         
                    d¦  «         
                    d¦  «        | _        | j         
                    d¦  «        | _        t/          j        ¦   «         }t1          j        | j         
                    d¦  «        j        |dz
  fdz  ¦  «         t1          j        | j        j        |dz
  fdz  ¦  «         |                      ¦   «          |                      ¦   «          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.
        NÚsystem_pathÚdevelopment_pathÚapplication_pathÚsystemTÚplugindummy_builtinÚdevÚappFÚplugindummy_appc                ó   — g | ]	}|j         ‘Œ
S r   ©r'   ©re   Úxs     r   rg   z-DeveloperSetupTests.setUp.<locals>.<listcomp>´  s   € ÐIÐIÐI A˜œÐIÐIÐIr   rÇ   rm   rV   zplugindummy_builtin.pyiˆ  r„   iÐ  )r&   r'   Ú	savedPathr)   r*   r+   r   r,   ÚfakeRootr.   r/   Ú
systemPathÚdevPathÚappPathrÌ   rÀ   ÚsystemPackageÚ
devPackageÚ
appPackageÚextendÚgetAllPluginsÚsysplugÚsyscacheÚtimerM   ÚutimeÚ
lockSystemÚresetEnvironment)r8   Únows     r   r9   zDeveloperSetupTests.setUp›  s  € õ œ ! ! !œˆŒÝœK×,Ò,Ñ.Ô.ˆÔÝ  §¢¡¤Ñ/Ô/ˆŒØŒ×%Ò%Ñ'Ô'Ð'Øœ-×-Ò-¨mÑ<Ô<ˆŒØ”}×*Ò*Ð+=Ñ>Ô>ˆŒØ”}×*Ò*Ð+=Ñ>Ô>ˆŒÝ/ØŒOÕ/°Ñ9Ô9¸4ÐAVñ
ô 
ˆÔõ -ØŒLÕ,¨UÑ3Ô3°TÐ;Pñ
ô 
ˆŒõ -ØŒLÕ,¨UÑ3Ô3°UÐ<Mñ
ô 
ˆŒõ
 	Œ�ŠÐIÐI¨$¬/¸4¼<Ð)HÐIÑIÔIÑJÔJÐJð 	×ÒÑÔÐØ”×,Ò,¨]Ñ;Ô;×AÒAÀ)ÑLÔLˆŒØœ×*Ò*¨>Ñ:Ô:ˆŒõ Œi‰kŒkˆÝ
Œ�”×#Ò#Ð$<Ñ=Ô=ÔBÀSÈ4ÁZÀMÐTUÑDUÑVÔVÐVÝ
Œ�”Ô# c¨D¡j ]°QÑ%6Ñ7Ô7Ð7ð 	�ŠÑÔÐØ×ÒÑÔÐÐÐr   c                ó‚   — t          j        | j        j        d¦  «         t          j        | j        j        d¦  «         dS )zW
        Lock the system directories, as if they were unwritable by this user.
        im  N©rM   r®   rê   r'   rë   r?   s    r   rî   zDeveloperSetupTests.lockSystemÅ  ó8   € õ 	Œ�”Ô" EÑ*Ô*Ð*Ý
Œ�”Ô# UÑ+Ô+Ð+Ð+Ð+r   c                ó‚   — t          j        | j        j        d¦  «         t          j        | j        j        d¦  «         dS )zW
        Unlock the system directories, as if they were writable by this user.
        iÿ  Nrò   r?   s    r   ÚunlockSystemz DeveloperSetupTests.unlockSystemÌ  ró   r   ú	list[str]c                óz   — ddl }t          t          j        t          |j        ¦  «        ¦  «        }d„ |D ¦   «         S )zl
        Get all the plugins loadable from our dummy package, and return their
        short names.
        r   Nc                ó   — g | ]	}|j         ‘Œ
S r   ©r   )re   Úplugs     r   rg   z5DeveloperSetupTests.getAllPlugins.<locals>.<listcomp>Ý  s   € Ð,Ð,Ð, $�”Ð,Ð,Ð,r   )Úplugindummy.pluginsr~   r
   r‡   r   rm   )r8   rÇ   rß   s      r   ré   z!DeveloperSetupTests.getAllPluginsÓ  sA   € ð 	#Ð"Ð"Ð"å•Ô"¥;°Ô0CÑDÔDÑEÔEˆØ,Ð,¨!Ð,Ñ,Ô,Ð,r   c                ó¤   — |                       ¦   «          t          j                             d„ | j        | j        | j        fD ¦   «         ¦  «         dS )zc
        Change the environment to what it should be just as the test is
        starting.
        c                ó   — g | ]	}|j         ‘Œ
S r   rÝ   rÞ   s     r   rg   z8DeveloperSetupTests.resetEnvironment.<locals>.<listcomp>å  s   € ÐWÐWÐW A˜œÐWÐWÐWr   N)ÚunsetEnvironmentr&   r'   rè   rã   râ   rä   r?   s    r   rï   z$DeveloperSetupTests.resetEnvironmentß  sL   € ð
 	×ÒÑÔÐÝŒ�ŠÐWÐW¨$¬,¸¼ÈÌÐ)VÐWÑWÔWÑXÔXÐXÐXÐXr   c                óÒ   — 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?   s    r   rþ   z$DeveloperSetupTests.unsetEnvironmentç  sR   € õ
 	Ñ Ô Ð ÝŒ×ÒÑÔÐÝŒ×Ò˜4Ô,Ñ-Ô-Ð-Ø”n�Œ���‰ˆˆr   c                óV   — |                       ¦   «          |                      ¦   «          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?   s    r   r@   zDeveloperSetupTests.tearDownñ  s0   € ð 	×ÒÑÔÐð
 	×ÒÑÔÐÐÐr   c                óª   — t          d¦  «        D ]B}|                      ¦   «         }|                     ¦   «          |                      |ddg¦  «         ŒCd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é   Úsortrj   )r8   rß   rŠ   s      r   Ú"test_developmentPluginAvailabilityz6DeveloperSetupTests.test_developmentPluginAvailabilityþ  s^   € õ �q‘”ð 	4ð 	4ˆAØ×&Ò&Ñ(Ô(ˆEØ�JŠJ‰LŒLˆLØ×Ò˜U U¨E NÑ3Ô3Ð3Ð3ð	4ð 	4r   c                óœ  — | j                              d¦  «        }|                     t          d¦  «        ¦  «         t	          j        ¦   «         dz
  }t          j        |j        ||f¦  «         |                     d¦  «        }t          d¬¦  «        }t          j        | j         j        fddi|¤Ž t          j        |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ž   ÚtwoN)rç   r/   r1   rÀ   rì   rM   rí   r'   r3   rÎ   Ú
compileallÚcompile_dirrN   rï   rk   ré   r’   )r8   Úmypathrß   ÚpycÚextras        r   Útest_freshPyReplacesStalePycz0DeveloperSetupTests.test_freshPyReplacesStalePyc  s�  € ð ”×&Ò& zÑ2Ô2ˆØ×ÒÕ,¨UÑ3Ô3Ñ4Ô4Ð4åŒI‰KŒK˜$ÑˆÝ
Œ�”˜q !˜fÑ%Ô%Ð%Ø�nŠn˜[Ñ)Ô)ˆõ "¨Ð.Ñ.Ô.ˆÝÔ˜tœÔ3ÐFÐF¸1ÐFÀÐFÐFÐFÝ
Œ�”˜A˜q˜6Ñ"Ô"Ð"à�Š‰Œˆà×ÒÑÔÐà�Š�e˜T×/Ò/Ñ1Ô1Ñ2Ô2Ð2Ø�Š�e˜T×/Ò/Ñ1Ô1Ñ2Ô2Ð2Ø×ÒÑÔÐØ×ÒÕ,¨UÑ3Ô3Ñ4Ô4Ð4Ø�Š�e˜T×/Ò/Ñ1Ô1Ñ2Ô2Ð2Ø�Š�e˜T×/Ò/Ñ1Ô1Ñ2Ô2Ð2Ð2Ð2r   c                ó|  — |                       ¦   «          | j                             d¦  «                             t	          d¦  «        ¦  «         |                      ¦   «          t          j                             | j	        j        ¦  «         g }t          |j        ¦  «         |                      t          |j        ¦  «         |                      d|                      ¦   «         ¦  «         d| j        j        t"          j        fz  }|D ]}t'          |¦  «        }|€J ‚||v r dS Œ|                      d|›�¦  «         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/   r1   rÀ   rî   r&   r'   rN   rã   r   r£   r¯   r   rk   ré   rë   r°   r±   r   r²   )r8   r´   rµ   r¶   r·   s        r   Útest_newPluginsOnReadOnlyPathz1DeveloperSetupTests.test_newPluginsOnReadOnlyPath,  sJ  € ð 	×ÒÑÔÐØŒ×Ò˜=Ñ)Ô)×4Ò4Õ5GÈÑ5NÔ5NÑOÔOÐOØ�ŠÑÔÐõ 	Œ�Š˜œÔ)Ñ*Ô*Ð*ð #%ˆÝ�F”MÑ"Ô"Ð"Ø�Š�¨¬Ñ6Ô6Ð6à�Š�e˜T×/Ò/Ñ1Ô1Ñ2Ô2Ð2ð IØŒMÔÝŒKðL
ñ 
ˆð ð 		ð 		ˆEÝ)¨%Ñ0Ô0ˆIØÐ(Ð(Ð(Ø˜9Ð$Ð$Ø��ð %ð �IŠIˆIà & ð)ñô ð ð ð r   Nr¹   )r    rö   )r   r   r   r   r9   rî   rõ   ré   rï   rþ   r@   r  r  r  r   r   r   rÒ   rÒ   ”  sì   € € € € € ðð ð( ð ( ð ( ð ( ðT,ð ,ð ,ð ,ð,ð ,ð ,ð ,ð
-ð 
-ð 
-ð 
-ðYð Yð Yð Yð%ð %ð %ð %ðð ð ð ð4ð 4ð 4ð 4ð3ð 3ð 3ð 3ð@&ð &ð &ð &ð &ð &r   rÒ   c                  ó:   — e Zd ZdZdd„Zdd„Zdd„Zdd„Z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                ó~   — 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?   s    r   r9   zAdjacentPackageTests.setUp[  s2   € õ  œH Q Q QœKˆÔÝœK×,Ò,Ñ.Ô.ˆÔÐÐr   c                ó¶   — | j         t          j        dd…<   t          j                             ¦   «          t          j                             | j        ¦  «         dS r;   r<   r?   s    r   r@   zAdjacentPackageTests.tearDownb  rA   r   r-   rÂ   rp   rº   Ú
pluginNamec                óò  — |                      |¦  «        }|                      d¦  «        }|                     ¦   «          |                      d¦  «                             d¦  «         |                      d¦  «        }|                     ¦   «          |                      d¦  «                             t          ¦  «         |                      |dz   ¦  «        }|                     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   rm   rÈ   )r/   Úmakedirsr1   rÉ   rÀ   )r8   r-   rp   r  Ú	directoryr0   rm   rÅ   s           r   ÚcreateDummyPackagez'AdjacentPackageTests.createDummyPackagej  sÔ   € ð, —J’J˜tÑ$Ô$ˆ	Ø—/’/ 'Ñ*Ô*ˆØ×ÒÑÔÐØ�Š�mÑ$Ô$×/Ò/°Ñ4Ô4Ð4Ø—-’- 	Ñ*Ô*ˆØ×ÒÑÔÐØ�Š�mÑ$Ô$×/Ò/µÑ?Ô?Ð?Ø—}’} Z°%Ñ%7Ñ8Ô8ˆØ×ÒÕ 2°4Ñ 8Ô 8Ñ9Ô9Ð9ØÐr   c                óþ  — t          |                      ¦   «         ¦  «        }|                     ¦   «          |                      |dd¦  «        }|                      |dd¦  «        }t          j                             |j        ¦  «         t          j                             |j        ¦  «         ddl}t          t          j
        t          |j        ¦  «        ¦  «        }|                      dg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.
        ÚfirstÚ
somepluginÚsecondr   Nc                ó   — g | ]	}|j         ‘Œ
S r   rù   rd   s     r   rg   zWAdjacentPackageTests.test_hiddenPackageSamePluginModuleNameObscured.<locals>.<listcomp>�  ó   € Ð$AÐ$AÐ$A°A Q¤ZÐ$AÐ$AÐ$Ar   ©r   r,   r  r  r&   r'   r£   Údummy.pluginsr~   r
   r‡   r   rm   rj   ©r8   r-   ÚfirstDirectoryÚsecondDirectoryr  rm   s         r   Ú.test_hiddenPackageSamePluginModuleNameObscuredzCAdjacentPackageTests.test_hiddenPackageSamePluginModuleNameObscured‹  ó×   € õ ˜Ÿš™œÑ&Ô&ˆØ�Š‰Œˆà×0Ò0°°wÀÑMÔMˆØ×1Ò1°$¸À,ÑOÔOˆåŒ�Š˜Ô+Ñ,Ô,Ð,ÝŒ�Š˜Ô,Ñ-Ô-Ð-àÐÐÐå•vÔ(­°e´mÑDÔDÑEÔEˆØ×Ò˜'˜Ð$AÐ$A¸Ð$AÑ$AÔ$AÑBÔBÐBÐBÐBr   c                óþ  — t          |                      ¦   «         ¦  «        }|                     ¦   «          |                      |dd¦  «        }|                      |dd¦  «        }t          j                             |j        ¦  «         t          j                             |j        ¦  «         ddl}t          t          j
        t          |j        ¦  «        ¦  «        }|                      dg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  Ú
thispluginr  Ú
thatpluginr   Nc                ó   — g | ]	}|j         ‘Œ
S r   rù   rd   s     r   rg   z\AdjacentPackageTests.test_hiddenPackageDifferentPluginModuleNameObscured.<locals>.<listcomp>±  r   r   r!  r#  s         r   Ú3test_hiddenPackageDifferentPluginModuleNameObscuredzHAdjacentPackageTests.test_hiddenPackageDifferentPluginModuleNameObscuredŸ  r'  r   Nr¹   )r-   rÂ   rp   rº   r  rº   r    rÂ   )	r   r   r   r   r9   r@   r  r&  r,  r   r   r   r  r  U  s�   € € € € € ðð ð
/ð /ð /ð /ð.ð .ð .ð .ðð ð ð ðBCð Cð Cð Cð(Cð Cð Cð Cð Cð Cr   r  c                  ó2   — e Zd ZdZd	d„Zd	d„Zd	d„Zd	d„ZdS )
ÚPackagePathTestszg
    Tests for L{plugin.pluginPackagePaths} which constructs search paths for
    plugin packages.
    r    r!   c                ó8   — t           j        dd…         | _        dS )z3
        Save the elements of C{sys.path}.
        N)r&   r'   r(   r?   s    r   r9   zPackagePathTests.setUpº  s   € õ  œH Q Q QœKˆÔÐÐr   c                ó2   — | j         t          j        dd…<   dS )z<
        Restore C{sys.path} to its original value.
        N)r(   r&   r'   r?   s    r   r@   zPackagePathTests.tearDownÀ  s   € ð Ô'�Œ���‰ˆˆr   c                ór  — t          d¦  «        }t          d¦  «        }|j        |j        gt          _        |                      t	          j        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  rm   N)r   r'   r&   rj   r
   ÚpluginPackagePathsr/   )r8   r2  r3  s      r   Útest_pluginDirectoriesz'PackagePathTests.test_pluginDirectoriesÆ  sŸ   € õ �u‰oŒoˆÝ�u‰oŒoˆØ”H˜cœhÐ'�ŒØ×ÒÝÔ% oÑ6Ô6à—	’	˜'Ñ"Ô"×(Ò(¨Ñ3Ô3Ô8Ø—	’	˜'Ñ"Ô"×(Ò(¨Ñ3Ô3Ô8ðñ	
ô 	
ð 	
ð 	
ð 	
r   c                ó€  — t          |                      ¦   «         ¦  «        }|                     d¦  «                             d¦  «                             d¦  «        }|                     ¦   «          |                     d¦  «                             d¦  «         |                     d¦  «        j        |                     d¦  «        j        gt          _        |                      t          j	        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.
        r2  r  rm   r$   r   r3  r4  N)
r   r,   r/   r  r1   r'   r&   rj   r
   r5  )r8   r-   r2  s      r   Útest_pluginPackagesExcludedz,PackagePathTests.test_pluginPackagesExcluded×  sþ   € õ ˜Ÿš™œÑ&Ô&ˆØ�jŠj˜ÑÔ×%Ò% gÑ.Ô.×4Ò4°YÑ?Ô?ˆØ�Š‰ŒˆØ�	Š	�-Ñ Ô ×+Ò+¨CÑ0Ô0Ð0Ø—J’J˜uÑ%Ô%Ô*¨D¯JªJ°uÑ,=Ô,=Ô,BÐC�ŒØ×ÒÝÔ% oÑ6Ô6Ø�ZŠZ˜ÑÔ×$Ò$ WÑ-Ô-×3Ò3°IÑ>Ô>ÔCÐDñ	
ô 	
ð 	
ð 	
ð 	
r   Nr¹   )r   r   r   r   r9   r@   r6  r8  r   r   r   r.  r.  ´  sn   € € € € € ðð ð
(ð (ð (ð (ð(ð (ð (ð (ð
ð 
ð 
ð 
ð"
ð 
ð 
ð 
ð 
ð 
r   r.  )rp   rº   r    r»   )
rÁ   rÂ   rÃ   r»   rÄ   rC   rÅ   rº   r    rÂ   )+r   Ú
__future__r   r	  r°   r^   rM   r&   rì   Ú	importlibr   r­   Útypesr   Útypingr   r   r   Úzope.interfacer	   Útwistedr
   Útwisted.python.filepathr   Útwisted.python.logr   r   r   r   Útwisted.trialr   r   r   r   ÚTestCaser   rÉ   rÀ   rÌ   rÎ   rÒ   r  r.  r   r   r   ú<module>rC     s¨  ðð
ð ð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø €€€Ø Ð Ð Ð Ø 	€	€	€	Ø 
€
€
€
Ø €€€Ø AÐ AÐ AÐ AÐ AÐ AØ Ð Ð Ð Ð Ð Ø /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /à $Ð $Ð $Ð $Ð $Ð $à Ð Ð Ð Ð Ð Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø XÐ XÐ XÐ XÐ XÐ XÐ XÐ XÐ XÐ XÐ XÐ XØ "Ð "Ð "Ð "Ð "Ð "à€WˆT�]„]€ðð ð ð ð �)ñ ô ð ðð ð ð ð �9ñ ô ð ðvð vð vð vð v�(Ô#ñ vô vð vðt	€ðð ð ð ð ð ð ð ð&ð ð ð ð ˜	ñ ô ð ð~ð ~ð ~ð ~ð ~˜(Ô+ñ ~ô ~ð ~ðB\Cð \Cð \Cð \Cð \C˜8Ô,ñ \Cô \Cð \Cð~4
ð 4
ð 4
ð 4
ð 4
�xÔ(ñ 4
ô 4
ð 4
ð 4
ð 4
r   