ó
    Ö›‘h°  ã                   óœ   • S r SSKrSSKJr  SSKJrJr  SSKJr  SSK	J
r   " S S\5      r " S	 S
\5      r " S S\5      r " S S\5      rg)z&
Tests for L{twisted.python.runtime}.
é    N)ÚnamedModule)ÚPlatformÚshortPythonVersion)ÚSynchronousTestCase)Úsuppressc                   ó"   • \ rS rSrSrSS jrSrg)ÚPythonVersionTestsé   z&
Tests the shortPythonVersion method.
Nc                 ó¶   • [        5       R                  S5      n[        S5       H1  nU R                  [	        X   5      [
        R                  U   5        M3     g)z5
Verify if the Python version is returned correctly.
Ú.é   N)r   ÚsplitÚrangeÚassertEqualÚintÚsysÚversion_info)ÚselfÚverÚis      ÚdC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/python/test/test_runtime.pyÚtest_shortPythonVersionÚ*PythonVersionTests.test_shortPythonVersion   sF   € ô !Ó"×(Ñ(¨Ó-ˆÜ�q–ˆAØ×ÑœS ¡›[¬#×*:Ñ*:¸1Ñ*=Ö>ò ó    © ©ÚreturnN)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Ú__static_attributes__r   r   r   r	   r	      s   † ñ÷?r   r	   c                   ó|   • \ rS 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
9/\
l        SS jrSS jrSrg)ÚPlatformTestsé   z0
Tests for the default L{Platform} initializer.
zgtwisted.python.runtime.Platform.isWinNT was deprecated in Twisted 13.0. Use Platform.isWindows instead.Nc                 óV   • [        5       nU R                  UR                  5       5        g)zh
L{Platform.isKnown} returns a boolean indicating whether this is one of
the L{runtime.knownPlatforms}.
N)r   Ú
assertTrueÚisKnown©r   Úplatforms     r   Útest_isKnownÚPlatformTests.test_isKnown)   s    € ô
 “:ˆØ�‰˜×(Ñ(Ó*Õ+r   c                 óþ   • [        5       nUR                  5       (       a^  U R                  UR                  5       5        U R                  UR	                  5       5        U R                  UR                  5       5        gg)z�
Verify consistency of L{Platform.isVista}: it can only be C{True} if
L{Platform.isWinNT} and L{Platform.isWindows} are C{True}.
N)r   ÚisVistar(   ÚisWinNTÚ	isWindowsÚassertFalseÚisMacOSXr*   s     r   Útest_isVistaConsistencyÚ%PlatformTests.test_isVistaConsistency1   s`   € ô
 “:ˆØ×Ñ×ÑØ�O‰O˜H×,Ñ,Ó.Ô/Ø�O‰O˜H×.Ñ.Ó0Ô1Ø×Ñ˜X×.Ñ.Ó0Õ1ð r   c                 ó„   • [        5       nUR                  5       (       a!  U R                  UR                  5       S5        gg)zY
L{Platform.isMacOSX} can only return C{True} if L{Platform.getType}
returns C{'posix'}.
ÚposixN)r   r3   r   ÚgetTyper*   s     r   Útest_isMacOSXConsistencyÚ&PlatformTests.test_isMacOSXConsistency<   s8   € ô
 “:ˆØ×Ñ×ÑØ×Ñ˜X×-Ñ-Ó/°Õ9ð r   c                 ó    • [        5       nUR                  5       (       a/  U R                  [        R                  R                  S5      5        gg)zƒ
L{Platform.isLinux} can only return C{True} if L{Platform.getType}
returns C{'posix'} and L{sys.platform} starts with C{"linux"}.
ÚlinuxN)r   ÚisLinuxr(   r   r+   Ú
startswithr*   s     r   Útest_isLinuxConsistencyÚ%PlatformTests.test_isLinuxConsistencyE   s:   € ô
 “:ˆØ×Ñ×ÑØ�O‰OœCŸL™L×3Ñ3°GÓ<Õ=ð r   c                 ó¨   • [        5       nUR                  5       nU R                  US5        UR                  5       S:w  a  U R	                  U5        gg)z~
L{Platform.isWinNT} can return only C{False} or C{True} and can not
return C{True} if L{Platform.getType} is not C{"win32"}.
)FTÚwin32N)r   r0   ÚassertInr8   r2   )r   r+   r0   s      r   Útest_isWinNTÚPlatformTests.test_isWinNTN   sK   € ô
 “:ˆØ×"Ñ"Ó$ˆØ�‰�g˜}Ô-Ø×ÑÓ Ó(Ø×Ñ˜WÕ%ð )r   )ÚcategoryÚmessagec                 óê   • [        5       nUR                  5         U R                  U R                  /5      nU R	                  [        U5      S5        U R	                  US   S   U R                  5        g)zF
L{Platform.isWinNT} is deprecated in favor of L{platform.isWindows}.
é   r   rG   N)r   r0   ÚflushWarningsÚtest_isWinNTDeprecatedr   ÚlenÚisWinNTDeprecationMessage)r   r+   Úwarningss      r   rK   Ú$PlatformTests.test_isWinNTDeprecated`   sc   € ô “:ˆØ×ÑÔØ×%Ñ% t×'BÑ'BÐ&CÓDˆØ×Ñœ˜X›¨Ô*Ø×Ñ˜ !™ YÑ/°×1OÑ1OÕPr   c                 óØ   •  [        S5        U R                  [        5       R                  5       5        g! [         a*    U R                  [        5       R                  5       5         gf = f)zl
L{Platform.supportsThreads} returns C{True} if threads can be created in
this runtime, C{False} otherwise.
Ú	threadingN)r   r(   r   ÚsupportsThreadsÚImportErrorr2   ©r   s    r   Útest_supportsThreadsÚ"PlatformTests.test_supportsThreadsj   sR   € ð	:Ü˜Ô$ð �O‰OœH›J×6Ñ6Ó8Õ9øô ó 	;Ø×ÑœX›Z×7Ñ7Ó9Ö:ð	;ús   ‚5 µ1A)Á(A)r   r   )r   r   r    r!   r"   rM   r,   r4   r9   r?   rD   ÚSUPRESSÚDeprecationWarningr   rK   rU   r#   r   r   r   r%   r%      sP   † ñð
	Fð ô
,ô	2ô:ô>ô	&ñ 	Ø'Ø-ñ	
ð€LÔôQ÷:r   r%   c                   ó6   • \ rS rSrSrSS jrSS jrSS jrSrg)	ÚForeignPlatformTestséz   z<
Tests for L{Platform} based overridden initializer values.
Nc                 óL  • U R                  [        S5      R                  5       S5        U R                  [        S5      R                  5       S5        U R                  [        S5      R                  5       S5        U R                  [        S5      R                  5       S5        g)z•
If an operating system name is supplied to L{Platform}'s initializer,
L{Platform.getType} returns the platform type which corresponds to that
name.
ÚntrB   Úcer7   ÚjavaN)r   r   r8   rT   s    r   Útest_getTypeÚ!ForeignPlatformTests.test_getType   sz   € ð 	×Ñœ $›×/Ñ/Ó1°7Ô;Ø×Ñœ $›×/Ñ/Ó1°7Ô;Ø×Ñœ 'Ó*×2Ñ2Ó4°gÔ>Ø×Ñœ &Ó)×1Ñ1Ó3°VÕ<r   c                 óú   • U R                  [        SS5      R                  5       5        U R                  [        SS5      R                  5       5        U R                  [        SS5      R                  5       5        g)z¼
If a system platform name is supplied to L{Platform}'s initializer, it
is used to determine the result of L{Platform.isMacOSX}, which returns
C{True} for C{"darwin"}, C{False} otherwise.
NÚdarwinÚlinux2rB   )r(   r   r3   r2   rT   s    r   Útest_isMacOSXÚ"ForeignPlatformTests.test_isMacOSXŠ   s\   € ð 	�‰œ  xÓ0×9Ñ9Ó;Ô<Ø×Ñœ $¨Ó1×:Ñ:Ó<Ô=Ø×Ñœ $¨Ó0×9Ñ9Ó;Õ<r   c                 óž  • U R                  [        SS5      R                  5       5        U R                  [        SS5      R                  5       5        U R                  [        SS5      R                  5       5        U R                  [        SS5      R                  5       5        U R                  [        SS5      R                  5       5        g)zÐ
If a system platform name is supplied to L{Platform}'s initializer, it
is used to determine the result of L{Platform.isLinux}, which returns
C{True} for values beginning with C{"linux"}, C{False} otherwise.
Nrc   r<   rd   Úlinux3rB   )r2   r   r=   r(   rT   s    r   Útest_isLinuxÚ!ForeignPlatformTests.test_isLinux”   s”   € ð 	×Ñœ $¨Ó1×9Ñ9Ó;Ô<Ø�‰œ  wÓ/×7Ñ7Ó9Ô:Ø�‰œ  xÓ0×8Ñ8Ó:Ô;Ø�‰œ  xÓ0×8Ñ8Ó:Ô;Ø×Ñœ $¨Ó0×8Ñ8Ó:Õ;r   r   r   )	r   r   r    r!   r"   r`   re   ri   r#   r   r   r   rZ   rZ   z   s   † ñô	=ô=÷
<r   rZ   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)
ÚDockerPlatformTestsé¡   z8
Tests for L{twisted.python.runtime.Platform.isDocker}.
Nc                 óZ   • [        SS5      nU R                  UR                  5       5        g)zF
If the platform is not Linux, C{isDocker()} always returns L{False}.
NrB   ©r   r2   ÚisDockerr*   s     r   Útest_noChecksOnLinuxÚ(DockerPlatformTests.test_noChecksOnLinux¦   s'   € ô ˜D 'Ó*ˆØ×Ñ˜×*Ñ*Ó,Õ-r   c                 óX   • [        SS5      nU R                  UR                  SS95        g)zk
If the platform is Linux, and the cgroups file in C{/proc} does not
exist, C{isDocker()} returns L{False}
Nr<   Úfakepath©Ú_initCGroupLocationro   r*   s     r   Útest_noCGroupsÚ"DockerPlatformTests.test_noCGroups­   s,   € ô
 ˜D 'Ó*ˆØ×Ñ˜×*Ñ*¸zÐ*ÐJÕKr   c                 óæ   • U R                  5       n[        US5       nUR                  S5        SSS5        [        SS5      nU R	                  UR                  US95        g! , (       d  f       N9= f)z–
If the platform is Linux, and the cgroups file (faked out here) exists,
and one of the paths starts with C{/docker/}, C{isDocker()} returns
C{True}.
Úwbsd  10:debug:/
9:net_prio:/
8:perf_event:/docker/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35f
7:net_cls:/
6:freezer:/docker/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35f
5:devices:/docker/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35f
4:blkio:/docker/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35f
3:cpuacct:/docker/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35f
2:cpu:/docker/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35f
1:cpuset:/docker/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35fNr<   ru   )ÚmktempÚopenÚwriter   r(   rp   ©r   ÚcgroupsFileÚfr+   s       r   Útest_cgroupsSuggestsDockerÚ.DockerPlatformTests.test_cgroupsSuggestsDockerµ   sc   € ð —k‘k“mˆÜ�+˜tÔ$¨à�G‰Gð	Uô÷ %ô ˜D 'Ó*ˆØ�‰˜×)Ñ)¸kÐ)ÐJÕK÷! %Õ$úó   �A"Á"
A0c                 óæ   • U R                  5       n[        US5       nUR                  S5        SSS5        [        SS5      nU R	                  UR                  US95        g! , (       d  f       N9= f)z˜
If the platform is Linux, and the cgroups file (faked out here) exists,
and none of the paths starts with C{/docker/}, C{isDocker()} returns
C{False}.
rz   sy   9:perf_event:/
8:blkio:/
7:net_cls:/
6:freezer:/
5:devices:/
4:memory:/
3:cpuacct,cpu:/
2:cpuset:/
1:name=systemd:/systemNr<   ru   )r{   r|   r}   r   r2   rp   r~   s       r   Útest_cgroupsSuggestsRealSystemÚ2DockerPlatformTests.test_cgroupsSuggestsRealSystemÎ   sd   € ð —k‘k“mˆÜ�+˜tÔ$¨à�G‰Gðô
÷ %ô ˜D 'Ó*ˆØ×Ñ˜×*Ñ*¸{Ð*ÐKÕL÷ %Õ$úrƒ   r   r   )
r   r   r    r!   r"   rq   rw   r�   r…   r#   r   r   r   rl   rl   ¡   s   † ñô.ôLôL÷2Mr   rl   )r"   r   Útwisted.python.reflectr   Útwisted.python.runtimer   r   Útwisted.trial.unittestr   Útwisted.trial.utilr   rW   r	   r%   rZ   rl   r   r   r   Ú<module>r‹      sW   ðñó
 å .ß ?Ý 6Ý 2ô?Ð,ô ?ôX:Ð'ô X:ôv$<Ð.ô $<ôNCMÐ-õ CMr   