ó
    ×›‘hh  ã                  óÞ  • S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKrSSK	J
r  SSKJr  SSKJrJrJr  SSKJr  SSKJr  SS	KJr  SS
KJrJrJrJr  SSKJr  \" S5      r " S S\5      r  " S S\5      r! " S S\RD                  5      r#Sr$SS jr%          SS jr& " S S\5      r' " S S\RD                  5      r( " S S\RD                  5      r) " S S\RD                  5      r*g) z"
Tests for Twisted plugin system.
é    )ÚannotationsN)Úinvalidate_caches)Ú
ModuleType)ÚCallableÚ	TypedDictÚTypeVar)Ú	Interface)Úplugin)ÚFilePath)Ú	EventDictÚaddObserverÚremoveObserverÚtextFromEventDict)ÚunittestÚ_Tc                  ó   • \ rS rSrSrSrg)ÚITestPluginé   zG
A plugin for use by the plugin system's unit tests.

Do not use this.
© N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r   ó    Ú\C:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/test/test_plugin.pyr   r      s   † ôr   r   c                  ó   • \ rS rSrSrSrg)ÚITestPlugin2é&   z
See L{ITestPlugin}.
r   Nr   r   r   r   r    r    &   s   † ôr   r    c                  ó  • \ rS rSrSrSS jrSS jr S     SS jjrSS jr    SS jr	\	SS j5       r
SS	 jr\	SS
 j5       r\	SS j5       r\	SS j5       r\	SS j5       r\	SS j5       r\	SS j5       rSS jrSrg)ÚPluginTestsé,   zS
Tests which verify the behavior of the current, active Twisted plugins
directory.
c                óÈ  • [         R                  SS U l        [         R                  R	                  5       U l        [        U R                  5       5      U l        U R                  R                  5         U R                  R                  S5      U l        U R                  R                  5         U R                  R                  S5      R                  S5        [        [        5      R                  S5      R                  U R                  R                  S5      5        SU l        [         R                  R#                  SU R                  R                  5        SSKnXl        g)	zF
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   ÚsetUpÚPluginTests.setUp2   sé   € ô  ŸH™H¡Q˜KˆÔÜŸK™K×,Ñ,Ó.ˆÔä˜TŸ[™[›]Ó+ˆŒ	Ø�	‰	×!Ñ!Ô#Ø—y‘y—‘ {Ó3ˆŒØ�‰×$Ñ$Ô&Ø�‰×Ñ˜=Ó)×4Ñ4°SÔ9ä”Ó×"Ñ"Ð#4Ó5×<Ñ<Ø�L‰L×Ñ˜Ó/ô	
ð +ˆÔä�‰�‰˜˜4Ÿ9™9Ÿ>™>Ô*Ûà�r   c                óÌ   • U R                   [        R                  SS& [        R                  R	                  5         [        R                  R                  U R                  5        g©zB
Restore C{sys.path} and C{sys.modules} to their original values.
N©r+   r)   r*   r,   ÚclearÚupdater.   ©r;   s    r   ÚtearDownÚPluginTests.tearDownJ   ó?   € ð ×'Ñ'Œ�‰‘ˆÜ�‰×ÑÔÜ�‰×Ñ˜4×,Ñ,Õ-r   c                ó¦  • UR                   c   eUR                  R                  S5      nSR                  US S 5      nUS   n[	        [
        R                  U   U5        [
        R                  UR                  	 SS/U=(       a    S/=(       d    / -    H'  n [        R                  " UR                   U-   5        M)     g ! [         a     M9  f = f)NÚ.éÿÿÿÿÚcÚoÚ )
r5   r   ÚsplitÚjoinÚdelattrr)   r,   ÚosÚremoveÚFileNotFoundError)r;   r:   ÚdeleteSourceÚ
modulePathÚpackageNameÚ
moduleNameÚexts          r   Ú_unimportPythonModuleÚ!PluginTests._unimportPythonModuleR   sµ   € ð �‰Ñ*Ð*Ð*Ø—_‘_×*Ñ*¨3Ó/ˆ
Ø—h‘h˜z¨#¨2˜Ó/ˆØ ‘^ˆ
ä”—‘˜KÑ(¨*Ô5Ü�K‰K˜Ÿ™Ð(Ø˜�: ×!6°2°$×!<¸"Ô=ˆCðÜ—	’	˜&Ÿ/™/¨CÑ/Ö0ò >øô %ó Úðús   Â#CÃ
CÃCc                óV   • U R                   R                  S5      R                  5         g)z+
Remove the plugins B{droping.cache} file.
údropin.cacheN)r3   r2   rQ   rC   s    r   Ú_clearCacheÚPluginTests._clearCacheb   s   € ð 	�‰×Ñ˜>Ó*×1Ñ1Õ3r   c                óJ   ^ • [         R                  " T 5      SU 4S jj5       nU$ )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.
c                óf   >• T" U 5        T" U 5        U R                  5         T" U 5        T" U 5        g )N)r\   )r;   Úmeths    €r   ÚwrappedÚ+PluginTests._withCacheness.<locals>.wrappedr   s+   ø€ á�ŒJÙ�ŒJØ×ÑÔÙ�ŒJÙ��Jr   )r;   r#   ÚreturnÚNone)Ú	functoolsÚwraps)r`   ra   s   ` r   Ú_withCachenessÚPluginTests._withCachenessh   s'   ø€ ô 
�Š˜Ó	ö	ó 
ð	ð ˆr   c                óZ  • [         R                  " U R                  5      nXR                     nU R	                  UR
                  SU R                   35        U R                  SUR                  5        UR                   Vs/ s H  n[        UR                  ;   d  M  UPM     snS   nU R                  UR                  U5        U R	                  UR                  S5        U R	                  UR                  R                  5       S5        U R	                  UR                  [        [         R                  /5        UR!                  5       nU R                  U["        R$                  SU R                   3   R&                  5        SSKJn  U R                  XVR&                  5        gs  snf )zá
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.r   Ú
TestPluginz*A plugin used solely for testing purposes.N)r
   ÚgetCacher:   r8   ÚassertEqualrV   ÚassertInÚdescriptionÚpluginsr   ÚprovidedÚassertIsÚdropinÚnameÚstripÚIPluginÚloadr)   r,   rj   Úmypackage.testpluginr(   )r;   Úcacherr   ÚpÚp1Ú
realPluginÚtps          r   Ú
test_cacheÚPluginTests.test_cache|   sD  € ô —’ §¡Ó,ˆà×*Ñ*Ñ+ˆØ×Ñ˜×*Ñ*¨j¸×9LÑ9LÐ8MÐ,NÔOØ�‰Ð+¨V×-?Ñ-?Ô@ð  ŸšÓEš�A¬;¸!¿*¹*Ñ+D�a™ÑEÀaÑHˆØ�‰�b—i‘i Ô(Ø×Ñ˜Ÿ™ ,Ô/ð 	×ÑØ�N‰N× Ñ Ó"Ð$Pô	
ð 	×Ñ˜Ÿ™¤{´F·N±NÐ&CÔDØ—W‘W“Yˆ
à�‰ØÜ�K‰K˜* T×%8Ñ%8Ð$9Ð:Ñ;×FÑFô	
õ 	*à�‰�j§-¡-Õ0ùò) Fs   ÂF(ÂF(c                óÒ   • [         R                  " U R                  5      U R                     n[	        S UR
                   5       5      S   nU R                  [        U5      S5        g)zU
L{CachedPlugin} has a helpful C{repr} which contains relevant
information about it.
c              3  óH   #   • U  H  oR                   S :X  d  M  Uv •  M     g7f)rj   N©rs   )Ú.0ry   s     r   Ú	<genexpr>Ú-PluginTests.test_cacheRepr.<locals>.<genexpr>§   s   é € ÐVÒ'; !¿v¹vÈÑ?UŸA™AÒ';ùs   ‚"™	"r   zT<CachedPlugin 'TestPlugin'/'mypackage.testplugin' (provides 'ITestPlugin, IPlugin')>N)r
   rk   r:   r8   Úlistro   rl   Úrepr)r;   ÚcachedDropinÚcachedPlugins      r   Útest_cacheReprÚPluginTests.test_cacheRepr¡   s\   € ô
 —’ t§{¡{Ó3°D×4GÑ4GÑHˆÜÑV |×';Ò';ÓVÓVØñ
ˆð 	×ÑÜ�Óð1õ	
r   c                ó  • [        [        R                  " [        U R                  5      5      nU R                  [        U5      S5        SS/nU H.  nUR                  UR                  5        UR                  5         M0     g)zò
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    r:   rl   ÚlenrQ   r   Útest)r;   ro   Únamesry   s       r   Útest_pluginsÚPluginTests.test_plugins°   sa   € ô ”v×(Ò(¬°t·{±{ÓCÓDˆà×Ñœ˜W› qÔ)à$Ð&7Ð8ˆÛˆAØ�L‰L˜Ÿ™Ô$Ø�F‰FŽHò r   c                óÄ  • [        [        5      R                  S5      R                  U R                  R                  S5      5         U R                  S[        R                  5        U R                  [        [        R                  S   S5      S5        [        [        R                  " [        U R                  5      5      nU R!                  [#        U5      S5        SS	/nU H.  nUR%                  UR&                  5        UR)                  5         M0     U R+                  [        R                  S   S
5        g! U R+                  [        R                  S   S
5        f = f)zM
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Œ   rj   ÚFourthTestPluginTN)r   r5   r6   r7   r3   r2   ÚfailIfInr)   r,   ÚassertFalseÚhasattrr…   r
   r�   r   r:   rl   r�   rQ   r   Útest1rX   ©r;   Úplgsr’   ry   s       r   Útest_detectNewFilesÚPluginTests.test_detectNewFilesÁ   s  € ô 	”Ó×"Ñ"Ð#5Ó6×=Ñ=Ø�L‰L×ÑÐ/Ó0ô	
ð	Sà�M‰MÐ1´3·;±;Ô?Ø×ÑÜœŸ™ KÑ0°-Ó@Ø8ôô
 œ×)Ò)¬+°t·{±{ÓCÓDˆDð ×ÑœS ›Y¨Ô*à!Ð#5Ð6ˆEÛ�Ø—‘˜QŸZ™ZÔ(Ø—‘–	ñ ð ×&Ñ&¤s§{¡{Ð3JÑ'KÈTÕRøˆD×&Ñ&¤s§{¡{Ð3JÑ'KÈTÕRús   ÁCD: Ä:%Ec                óŒ  • [        [        5      R                  S5      R                  U R                  R                  S5      5         [        [        R                  " [        U R                  5      5      nU R                  [        U5      S5        [        [        5      R                  S5      R                  U R                  R                  S5      5        U R                  [        R                  S   5        [        [        R                  " [        U R                  5      5      nU R                  [        U5      S5        / SQnU H.  nUR!                  UR"                  5        UR%                  5         M0     U R                  [        R                  S   S5        g	! U R                  [        R                  S   S5        f = f)
zm
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˜   é   )rj   rš   ÚFifthTestPluginTN)r   r5   r6   r7   r3   r2   r…   r
   r�   r   r:   rl   r�   rX   r)   r,   rQ   r   rž   rŸ   s       r   Útest_detectFilesChangedÚ#PluginTests.test_detectFilesChangedß   sG  € ô 	”Ó×"Ñ"Ð#5Ó6×=Ñ=Ø�L‰L×ÑÐ/Ó0ô	
ð	SÜœ×)Ò)¬+°t·{±{ÓCÓDˆDà×ÑœS ›Y¨Ô*ä”XÓ×&Ñ&Ð'9Ó:×AÑAØ—‘×"Ñ"Ð#3Ó4ôð
 ×&Ñ&¤s§{¡{Ð3JÑ'KÔLô œ×)Ò)¬+°t·{±{ÓCÓDˆDà×ÑœS ›Y¨Ô*âIˆEÛ�Ø—‘˜QŸZ™ZÔ(Ø—‘–	ñ ð ×&Ñ&¤s§{¡{Ð3JÑ'KÈTÕRøˆD×&Ñ&¤s§{¡{Ð3JÑ'KÈTÕRús   ÁD2F Æ%Gc                ó  • [        [        5      R                  S5      R                  U R                  R                  S5      5         [        [        R                  " [        U R                  5      5        U R                  [        R                  S   S5        [        [        R                  " [        U R                  5      5      nU R                  S[        U5      5        g! U R                  [        R                  S   S5        f = f)z[
Check that when a dropin file is removed, L{plugin.getPlugins} doesn't
return it anymore.
r–   r—   r˜   Té   N)r   r5   r6   r7   r3   r2   r…   r
   r�   r   r:   rX   r)   r,   rl   r�   )r;   r    s     r   Útest_detectFilesRemovedÚ#PluginTests.test_detectFilesRemoved   s¾   € ô 	”Ó×"Ñ"Ð#5Ó6×=Ñ=Ø�L‰L×ÑÐ/Ó0ô	
ð	Sä”×"Ò"¤;°·±Ó<Ô=ð ×&Ñ&¤s§{¡{Ð3JÑ'KÈTÔRÜ”F×%Ò%¤k°4·;±;Ó?Ó@ˆØ×Ñ˜œC ›IÕ&øð ×&Ñ&¤s§{¡{Ð3JÑ'KÈTÕRús   Á.C# Ã#%Dc                óü  • U R                  5       nU R                  [        R                  R	                  U5      5        U R
                  R                  R                  U5         [        [        R                  " [        U R
                  5      5      nU R                  [        U5      S5        U R
                  R                  R                  U5        g! U R
                  R                  R                  U5        f = f)za
Test that getCache skips over any entries in a plugin package's
C{__path__} which do not exist.
r©   N)r/   rœ   rP   r*   Úexistsr:   Ú__path__Úappendr…   r
   r�   r   rl   r�   rQ   )r;   r*   r    s      r   Útest_nonexistentPathEntryÚ%PluginTests.test_nonexistentPathEntry  s§   € ð �{‰{‹}ˆØ×ÑœŸ™Ÿ™¨Ó-Ô.à�‰×Ñ×#Ñ# DÔ)ð	.Üœ×)Ò)¬+°t·{±{ÓCÓDˆDØ×ÑœS ›Y¨Ô*à�K‰K× Ñ ×'Ñ'¨Õ-øˆD�K‰K× Ñ ×'Ñ'¨Õ-ús   Á%A	C Ã'C;c                óF  • [        U R                  5       5      nU R                  UR                  5       5        UR	                  5         UR                  S5      R                  nU R                  R                  R                  U5         [        [        R                  " [        U R                  5      5      nU R                  [        U5      S5        U R                  R                  R!                  U5        g! U R                  R                  R!                  U5        f = f)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­   Útouchr2   r*   r:   r®   r¯   r…   r
   r�   r   rl   r�   rQ   )r;   r*   r2   r    s       r   Útest_nonDirectoryChildEntryÚ'PluginTests.test_nonDirectoryChildEntry"  sÂ   € ô ˜Ÿ™›Ó&ˆØ×Ñ˜Ÿ™›Ô'Ø�
‰
ŒØ—
‘
˜>Ó*×/Ñ/ˆØ�‰×Ñ×#Ñ# EÔ*ð	/Üœ×)Ò)¬+°t·{±{ÓCÓDˆDØ×ÑœS ›Y¨Ô*à�K‰K× Ñ ×'Ñ'¨Õ.øˆD�K‰K× Ñ ×'Ñ'¨Õ.ús   Â
A	C9 Ã9'D c                ó$  • [         R                  " U R                  5        U R                  R	                  S5      n[        [        5      R                  S5      R                  U R                  R	                  S5      5        [        5         [        R                  " U R                  R                  S5        [        R                  " UR                  S5        U R                  [        R                  U R                  R                  S5        U R                  [        R                  UR                  S5        / n[        UR                  5        U R                  [         UR                  5        [         R                  " U R                  5      nU R#                  SU5        U R#                  U R$                  U5        SUR                  [&        R(                  4-  nU H  n[+        U5      nUc   eXF;   d  M    g	   U R-                  S
U< 35        g	)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.
r[   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
   rk   r:   r3   r2   r   r5   r6   r7   ÚinvalidateImportCachesrP   Úchmodr*   Ú
addCleanupr   r¯   r   rm   r8   ÚerrnoÚEPERMr   Úfail)r;   Ú	cachepathÚeventsrx   ÚexpectedÚeventÚ	maybeTexts          r   Útest_deployedModeÚPluginTests.test_deployedMode3  s  € ô 	�Š˜Ÿ™Ô$à—L‘L×&Ñ& ~Ó6ˆ	ô 	”Ó×"Ñ"Ð#5Ó6×=Ñ=Ø�L‰L×ÑÐ/Ó0ô	
ô 	Ô ä
�Š�—‘×"Ñ" EÔ*ä
�Š�—‘ Ô'Ø�‰œŸ™ $§,¡,×"3Ñ"3°UÔ;Ø�‰œŸ™ )§.¡.°%Ô8ð #%ˆÜ�F—M‘MÔ"Ø�‰œ¨¯©Ô6ä—’ §¡Ó,ˆà�‰�m UÔ+Ø�‰�d×)Ñ)¨5Ô1ð IØ�N‰NÜ�K‰KðL
ñ 
ˆó ˆEÜ)¨%Ó0ˆIØÑ(Ð(Ð(ØÕ$Ùñ	 ð �IŠIâ &ð)õr   )r:   r+   r8   r3   r0   r.   N©rc   rd   )F)r:   r   rS   Úboolrc   rd   )r`   zCallable[[PluginTests], object]rc   zCallable[[PluginTests], None])r   r   r   r   r   r<   rD   rX   r\   rg   r}   r‰   r“   r¡   r¦   rª   r°   rµ   rÆ   r   r   r   r   r#   r#   ,   sé   † ñô
 ô0.ð 8=ðØ ðØ04ðà	õô 4ðØ-ðà	&ôð( ó"1ó ð"1ôH
ð óó ðð  óSó ðSð: óSó ðSð@ ó'ó ð'ð" ó.ó ð.ð ó/ó ð/÷ /r   r#   sj   
from twisted.plugin import pluginPackagePaths
__path__.extend(pluginPackagePaths(__name__))
__all__ = []
c                óB   • SR                  U 5      R                  S5      $ )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   c                ó”  • U R                  5         U R                  S5      nUR                  5         U(       a   UR                  S5      R                  S5        UR                  S5      nUR                  5         U(       a$  UR                  S5      R                  [        5        UR                  US-   5      R                  U5        U$ )z
Create a plugindummy package.
Úplugindummyr'   r   ro   ú.py)r1   r2   r4   ÚpluginInitFile)Ú	entrypathÚpluginContentÚrealÚpluginModuleÚpkgÚplugss         r   Ú_createPluginDummyrÙ   }  s™   € ð ×ÑÔØ
�/‰/˜-Ó
(€CØ×ÑÔÞØ�	‰	�-Ó ×+Ñ+¨CÔ0Ø�I‰I�iÓ €EØ	×ÑÔÞØ�‰�MÓ"×-Ñ-¬nÔ=Ø	‡K�K�˜uÑ$Ó%×0Ñ0°Ô?Ø€Lr   c                  ó    • \ rS rSr% S\S'   Srg)Ú_HasBoolLegacyKeyi�  rÉ   Úlegacyr   N)r   r   r   r   Ú__annotations__r   r   r   r   rÛ   rÛ   �  s   ‡ Ø†Lr   rÛ   c                  ó|   • \ rS rSrSrSS jrSS jrSS jrSS jrSS jr	SS jr
SS	 jrSS
 jrSS jrSS jrSrg)ÚDeveloperSetupTestsi”  z£
These tests verify things about the plugin system without actually
interacting with the deployed 'twisted.plugins' package, instead creating a
temporary package.
c                óD  • [         R                  SS U l        [         R                  R	                  5       U l        [        U R                  5       5      U l        U R                  R                  5         U R                  R                  S5      U l        U R                  R                  S5      U l        U R                  R                  S5      U l        [        U R                  [        S5      SS5      U l        [        U R                  [        S5      SS5      U l        [        U R                  [        S	5      S
S5      U l        [         R                  R'                  U R                  U R                  4 Vs/ s H  oR                  PM     sn5        U R)                  5         U R                  R                  S5      R                  S5      U l        U R*                  R                  S5      U l        [.        R.                  " 5       n[0        R2                  " U R*                  R                  S5      R                  US-
  4S-  5        [0        R2                  " U R,                  R                  US-
  4S-  5        U R5                  5         U R7                  5         gs  snf )a  
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_apprÐ   ro   r[   zplugindummy_builtin.pyiˆ  rŒ   iÐ  )r)   r*   Ú	savedPathr,   r-   r.   r   r/   ÚfakeRootr1   r2   Ú
systemPathÚdevPathÚappPathrÙ   rÎ   ÚsystemPackageÚ
devPackageÚ
appPackageÚextendÚgetAllPluginsÚsysplugÚsyscacheÚtimerP   ÚutimeÚ
lockSystemÚresetEnvironment)r;   ÚxÚnows      r   r<   ÚDeveloperSetupTests.setUp›  sè  € ô Ÿ™¡!˜ˆŒÜŸK™K×,Ñ,Ó.ˆÔÜ  §¡£Ó/ˆŒØ�‰×%Ñ%Ô'ØŸ-™-×-Ñ-¨mÓ<ˆŒØ—}‘}×*Ñ*Ð+=Ó>ˆŒØ—}‘}×*Ñ*Ð+=Ó>ˆŒÜ/Ø�O‰OÔ/°Ó9¸4ÐAVó
ˆÔô -Ø�L‰LÔ,¨UÓ3°TÐ;Pó
ˆŒô -Ø�L‰LÔ,¨UÓ3°UÐ<Mó
ˆŒô
 	�‰�‰¨$¯/©/¸4¿<¹<Ñ)HÓIÒ)H AŸœÑ)HÑIÔJð 	×ÑÔØ—‘×,Ñ,¨]Ó;×AÑAÀ)ÓLˆŒØŸ™×*Ñ*¨>Ó:ˆŒô �iŠi‹kˆÜ
�Š�—‘×#Ñ#Ð$<Ó=×BÑBÀSÈ4ÁZÀMÐTUÑDUÔVÜ
�Š�—‘×#Ñ# c¨D¡j ]°QÑ%6Ô7ð 	�‰ÔØ×ÑÕùò Js   Å9Jc                ó°   • [         R                  " U R                  R                  S5        [         R                  " U R                  R                  S5        g)zG
Lock the system directories, as if they were unwritable by this user.
im  N©rP   r¼   ró   r*   rô   rC   s    r   r÷   ÚDeveloperSetupTests.lockSystemÅ  ó4   € ô 	�Š�—‘×"Ñ" EÔ*Ü
�Š�—‘×#Ñ# UÕ+r   c                ó°   • [         R                  " U R                  R                  S5        [         R                  " U R                  R                  S5        g)zG
Unlock the system directories, as if they were writable by this user.
iÿ  Nrý   rC   s    r   ÚunlockSystemÚ DeveloperSetupTests.unlockSystemÌ  rÿ   r   c                ó¨   • SSK n[        [        R                  " [        UR
                  5      5      nU Vs/ s H  o3R                  PM     sn$ s  snf )zT
Get all the plugins loadable from our dummy package, and return their
short names.
r   N)Úplugindummy.pluginsr…   r
   r�   r   ro   r   )r;   rÐ   rù   Úplugs       r   rò   Ú!DeveloperSetupTests.getAllPluginsÓ  s>   € ó 	#ä”×"Ò"¤;°×0CÑ0CÓDÓEˆÙ*+Ó,ª! $—”©!Ñ,Ð,ùÒ,s   ·Ac                óâ   • U R                  5         [        R                  R                  U R                  U R
                  U R                  4 Vs/ s H  oR                  PM     sn5        gs  snf )zK
Change the environment to what it should be just as the test is
starting.
N)ÚunsetEnvironmentr)   r*   rñ   rì   rë   rí   )r;   rù   s     r   rø   Ú$DeveloperSetupTests.resetEnvironmentß  sI   € ð
 	×ÑÔÜ�‰�‰¨$¯,©,¸¿¹ÈÏÉÑ)VÓWÒ)V AŸœÑ)VÑWÕXùÒWs   ÁA,c                óà   • [        5         [        R                  R                  5         [        R                  R	                  U R
                  5        U R                  [        R                  SS& g)zP
Change the Python environment back to what it was before the test was
started.
N)r»   r)   r,   rA   rB   r.   ré   r*   rC   s    r   r  Ú$DeveloperSetupTests.unsetEnvironmentç  sC   € ô
 	Ô Ü�‰×ÑÔÜ�‰×Ñ˜4×,Ñ,Ô-Ø—n‘nŒ�‰‘‰r   c                óD   • U R                  5         U R                  5         g)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  rC   s    r   rD   ÚDeveloperSetupTests.tearDownñ  s   € ð 	×ÑÔð
 	×ÑÕr   c                ó�   • [        S5       H7  nU R                  5       nUR                  5         U R                  USS/5        M9     g)zì
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ò   Úsortrl   )r;   rù   r’   s      r   Ú"test_developmentPluginAvailabilityÚ6DeveloperSetupTests.test_developmentPluginAvailabilityþ  s=   € ô �q–ˆAØ×&Ñ&Ó(ˆEØ�J‰JŒLØ×Ñ˜U U¨E NÖ3ò r   c                óH  • U R                   R                  S5      nUR                  [        S5      5        [        R                  " 5       S-
  n[
        R                  " UR                  X"45        UR                  S5      n[        SS9n[        R                  " U R                   R                  4SS0UD6  [
        R                  " UR                  X"45        UR                  5         U R                  5         U R                  SU R                  5       5        U R!                  S	U R                  5       5        U R                  5         UR                  [        S	5      5        U R!                  SU R                  5       5        U R                  S	U R                  5       5        g
)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ð   r2   r4   rÎ   rõ   rP   rö   r*   r6   rÛ   Ú
compileallÚcompile_dirrQ   rø   rm   rò   r›   )r;   Úmypathrù   ÚpycÚextras        r   Útest_freshPyReplacesStalePycÚ0DeveloperSetupTests.test_freshPyReplacesStalePyc  s1  € ð —‘×&Ñ& zÓ2ˆØ×ÑÔ,¨UÓ3Ô4ä�IŠI‹K˜$ÑˆÜ
�Š�—‘˜q˜fÔ%Ø�n‰n˜[Ó)ˆô "¨Ñ.ˆÜ×Ò˜tŸ™×3Ñ3ÑF¸1ÐFÀÒFÜ
�Š�—‘˜A˜6Ô"à�‰Œà×ÑÔà�‰�e˜T×/Ñ/Ó1Ô2Ø�‰�e˜T×/Ñ/Ó1Ô2Ø×ÑÔØ×ÑÔ,¨UÓ3Ô4Ø�‰�e˜T×/Ñ/Ó1Ô2Ø�‰�e˜T×/Ñ/Ó1Õ2r   c                óz  • U R                  5         U R                  R                  S5      R                  [	        S5      5        U R                  5         [        R                  R                  U R                  R                  5        / n[        UR                  5        U R                  [        UR                  5        U R                  SU R                  5       5        SU R                   R                  ["        R$                  4-  nU H  n['        U5      nUc   eX$;   d  M    g   U R)                  SU< 35        g)a  
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ó   r2   r4   rÎ   r÷   r)   r*   rQ   rì   r   r¯   r½   r   rm   rò   rô   r¾   r¿   r   rÀ   )r;   rÂ   rÃ   rÄ   rÅ   s        r   Útest_newPluginsOnReadOnlyPathÚ1DeveloperSetupTests.test_newPluginsOnReadOnlyPath,  sý   € ð 	×ÑÔØ�‰×Ñ˜=Ó)×4Ñ4Ô5GÈÓ5NÔOØ�‰Ôô 	�‰�‰˜Ÿ™×)Ñ)Ô*ð #%ˆÜ�F—M‘MÔ"Ø�‰œ¨¯©Ô6à�‰�e˜T×/Ñ/Ó1Ô2ð IØ�M‰M×ÑÜ�K‰KðL
ñ 
ˆó ˆEÜ)¨%Ó0ˆIØÑ(Ð(Ð(ØÕ$Ùñ	 ð �IŠIâ &ð)õr   )rð   rí   rï   rì   rê   r.   ré   rô   ró   rî   rë   NrÈ   )rc   z	list[str])r   r   r   r   r   r<   r÷   r  rò   rø   r  rD   r  r  r  r   r   r   r   rß   rß   ”  s<   † ñô( ôT,ô,ô
-ôYô%ôô4ô3÷@&r   rß   c                  óZ   • \ rS rSrSrS
S jrS
S jr        SS jrS
S jrS
S jr	Sr
g	)ÚAdjacentPackageTestsiU  zŠ
Tests for the behavior of the plugin system when there are multiple
installed copies of the package containing the plugins being loaded.
c                óz   • [         R                  SS U l        [         R                  R	                  5       U l        g)zC
Save the elements of C{sys.path} and the items of C{sys.modules}.
N)r)   r*   r+   r,   r-   r.   rC   s    r   r<   ÚAdjacentPackageTests.setUp[  s)   € ô  ŸH™H¡Q˜KˆÔÜŸK™K×,Ñ,Ó.ˆÕr   c                óÌ   • U R                   [        R                  SS& [        R                  R	                  5         [        R                  R                  U R                  5        gr?   r@   rC   s    r   rD   ÚAdjacentPackageTests.tearDownb  rF   r   c                ó�  • UR                  U5      nUR                  S5      nUR                  5         UR                  S5      R                  S5        UR                  S5      nUR                  5         UR                  S5      R                  [        5        UR                  US-   5      nUR                  [	        U5      5        U$ )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   ro   rÑ   )r2   Úmakedirsr4   rÒ   rÎ   )r;   r0   rs   Ú
pluginNameÚ	directoryr3   ro   rÖ   s           r   ÚcreateDummyPackageÚ'AdjacentPackageTests.createDummyPackagej  s¡   € ð, —J‘J˜tÓ$ˆ	Ø—/‘/ 'Ó*ˆØ×ÑÔØ�‰�mÓ$×/Ñ/°Ô4Ø—-‘- 	Ó*ˆØ×ÑÔØ�‰�mÓ$×/Ñ/´Ô?Ø—}‘} Z°%Ñ%7Ó8ˆØ×ÑÔ 2°4Ó 8Ô9ØÐr   c                ó  • [        U R                  5       5      nUR                  5         U R                  USS5      nU R                  USS5      n[        R
                  R                  UR
                  5        [        R
                  R                  UR
                  5        SSKn[        [        R                  " [        UR                  5      5      nU R                  S/U Vs/ s H  ofR                  PM     sn5        gs  snf )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   N©r   r/   r)  r,  r)   r*   r¯   Údummy.pluginsr…   r
   r�   r   ro   rl   r   ©r;   r0   ÚfirstDirectoryÚsecondDirectoryr(  ro   ry   s          r   Ú.test_hiddenPackageSamePluginModuleNameObscuredÚCAdjacentPackageTests.test_hiddenPackageSamePluginModuleNameObscured‹  óµ   € ô ˜Ÿ™›Ó&ˆØ�‰Œà×0Ñ0°°wÀÓMˆØ×1Ñ1°$¸À,ÓOˆä�‰�‰˜×+Ñ+Ô,Ü�‰�‰˜×,Ñ,Ô-ãä”v×(Ò(¬°e·m±mÓDÓEˆØ×Ñ˜'˜¹Ó$Aº°A§Z¤Z¹Ñ$AÕBùÒ$Aó   Ã%D
c                ó  • [        U R                  5       5      nUR                  5         U R                  USS5      nU R                  USS5      n[        R
                  R                  UR
                  5        [        R
                  R                  UR
                  5        SSKn[        [        R                  " [        UR                  5      5      nU R                  S/U Vs/ s H  ofR                  PM     sn5        gs  snf )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/  Ú
thispluginr1  Ú
thatpluginr   Nr2  r4  s          r   Ú3test_hiddenPackageDifferentPluginModuleNameObscuredÚHAdjacentPackageTests.test_hiddenPackageDifferentPluginModuleNameObscuredŸ  r9  r:  )r+   r.   NrÈ   )r0   úFilePath[str]rs   Ústrr*  rA  rc   r@  )r   r   r   r   r   r<   rD   r,  r7  r>  r   r   r   r   r"  r"  U  sC   † ñô
/ô.ðØ!ðØ),ðØ:=ðà	ôôBC÷(Cr   r"  c                  ó@   • \ rS rSrSrS	S jrS	S jrS	S jrS	S jrSr	g)
ÚPackagePathTestsi´  z[
Tests for L{plugin.pluginPackagePaths} which constructs search paths for
plugin packages.
c                ó4   • [         R                  SS U l        g)z#
Save the elements of C{sys.path}.
N)r)   r*   r+   rC   s    r   r<   ÚPackagePathTests.setUpº  s   € ô  ŸH™H¡Q˜KˆÕr   c                ó>   • U R                   [        R                  SS& g)z,
Restore C{sys.path} to its original value.
N)r+   r)   r*   rC   s    r   rD   ÚPackagePathTests.tearDownÀ  s   € ð ×'Ñ'Œ�‰‘‰r   c                ób  • [        S5      n[        S5      nUR                  UR                  /[        l        U R                  [        R
                  " S5      UR                  S5      R                  S5      R                  UR                  S5      R                  S5      R                  /5        g)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(  ro   N)r   r*   r)   rl   r
   ÚpluginPackagePathsr2   )r;   rI  rJ  s      r   Útest_pluginDirectoriesÚ'PackagePathTests.test_pluginDirectoriesÆ  s…   € ô �u‹oˆÜ�u‹oˆØ—H‘H˜cŸh™hÐ'ŒŒØ×ÑÜ×%Ò% oÓ6à—	‘	˜'Ó"×(Ñ(¨Ó3×8Ñ8Ø—	‘	˜'Ó"×(Ñ(¨Ó3×8Ñ8ðõ	
r   c                ó.  • [        U R                  5       5      nUR                  S5      R                  S5      R                  S5      nUR                  5         UR                  S5      R	                  S5        UR                  S5      R
                  UR                  S5      R
                  /[        l        U R                  [        R                  " S5      UR                  S5      R                  S5      R                  S5      R
                  /5        g)	aa  
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.
rI  r(  ro   r'   r   rJ  rK  N)
r   r/   r2   r)  r4   r*   r)   rl   r
   rL  )r;   r0   rI  s      r   Útest_pluginPackagesExcludedÚ,PackagePathTests.test_pluginPackagesExcluded×  sÉ   € ô ˜Ÿ™›Ó&ˆØ�j‰j˜Ó×%Ñ% gÓ.×4Ñ4°YÓ?ˆØ�‰ŒØ�	‰	�-Ó ×+Ñ+¨CÔ0Ø—J‘J˜uÓ%×*Ñ*¨D¯J©J°uÓ,=×,BÑ,BÐCŒŒØ×ÑÜ×%Ò% oÓ6Ø�Z‰Z˜Ó×$Ñ$ WÓ-×3Ñ3°IÓ>×CÑCÐDõ	
r   )r+   NrÈ   )
r   r   r   r   r   r<   rD   rM  rP  r   r   r   r   rC  rC  ´  s   † ñô
(ô(ô
÷"
r   rC  )rs   rA  rc   Úbytes)
rÓ   r@  rÔ   rR  rÕ   rÉ   rÖ   rA  rc   r@  )+r   Ú
__future__r   r  r¾   re   rP   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"  rC  r   r   r   Ú<module>r]     sø   ðñ
õ #ã Û Û Û 	Û 
Û Ý AÝ ß /Ñ /å $å Ý ,ß XÓ XÝ "áˆTƒ]€ô�)ô ô�9ô ôv�(×#Ñ#ô vðt	€ôð ØðØ-2ðØ:>ðØNQðàôô&˜	ô ô~˜(×+Ñ+ô ~ôB\C˜8×,Ñ,ô \Cô~4
�x×(Ñ(õ 4
r   