Ë
    oj°  ã                   óœ   — d Z ddlZddlmZ ddlmZmZ ddlmZ ddl	m
Z  G d„ de«      Z G d	„ d
e«      Z G d„ de«      Z G d„ de«      Zy)z&
Tests for L{twisted.python.runtime}.
é    N)ÚnamedModule)ÚPlatformÚshortPythonVersion)ÚSynchronousTestCase)Úsuppressc                   ó   — e Zd ZdZdd„Zy)ÚPythonVersionTestsz.
    Tests the shortPythonVersion method.
    Nc                 ó´   — t        «       j                  d«      }t        d«      D ]1  }| j                  t	        ||   «      t
        j                  |   «       Œ3 y)zE
        Verify if the Python version is returned correctly.
        ú.é   N)r   ÚsplitÚrangeÚassertEqualÚintÚsysÚversion_info)ÚselfÚverÚis      úB/usr/lib/python3/dist-packages/twisted/python/test/test_runtime.pyÚtest_shortPythonVersionz*PythonVersionTests.test_shortPythonVersion   sM   € ô !Ó"×(Ñ(¨Ó-ˆÜ�q“ò 	?ˆAØ×ÑœS  Q¡›[¬#×*:Ñ*:¸1Ñ*=Õ>ñ	?ó    ©ÚreturnN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   © r   r   r	   r	      s   „ ñô?r   r	   c                   ól   — e Zd ZdZdZdd„Zdd„Zdd„Zdd„Zdd„Z	 e
ee¬	«      ge	_        dd
„Zdd„Zy)ÚPlatformTestsz8
    Tests for the default L{Platform} initializer.
    zgtwisted.python.runtime.Platform.isWinNT was deprecated in Twisted 13.0. Use Platform.isWindows instead.Nc                 óV   — t        «       }| j                  |j                  «       «       y)z€
        L{Platform.isKnown} returns a boolean indicating whether this is one of
        the L{runtime.knownPlatforms}.
        N)r   Ú
assertTrueÚisKnown©r   Úplatforms     r   Útest_isKnownzPlatformTests.test_isKnown)   s    € ô
 “:ˆØ�‰˜×(Ñ(Ó*Õ+r   c                 óô   — t        «       }|j                  «       r^| j                  |j                  «       «       | j                  |j	                  «       «       | j                  |j                  «       «       yy)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_isVistaConsistencyz%PlatformTests.test_isVistaConsistency1   s]   € ô
 “:ˆØ×ÑÔØ�O‰O˜H×,Ñ,Ó.Ô/Ø�O‰O˜H×.Ñ.Ó0Ô1Ø×Ñ˜X×.Ñ.Ó0Õ1ð r   c                 óz   — t        «       }|j                  «       r!| j                  |j                  «       d«       yy)zq
        L{Platform.isMacOSX} can only return C{True} if L{Platform.getType}
        returns C{'posix'}.
        ÚposixN)r   r-   r   ÚgetTyper%   s     r   Útest_isMacOSXConsistencyz&PlatformTests.test_isMacOSXConsistency<   s5   € ô
 “:ˆØ×ÑÔØ×Ñ˜X×-Ñ-Ó/°Õ9ð r   c                 ó–   — t        «       }|j                  «       r/| j                  t        j                  j                  d«      «       yy)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_isLinuxConsistencyz%PlatformTests.test_isLinuxConsistencyE   s7   € ô
 “:ˆØ×ÑÔØ�O‰OœCŸL™L×3Ñ3°GÓ<Õ=ð r   c                 ó¦   — t        «       }|j                  «       }| j                  |d«       |j                  «       dk7  r| j	                  |«       yy)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   r*   ÚassertInr1   r,   )r   r&   r*   s      r   Útest_isWinNTzPlatformTests.test_isWinNTN   sK   € ô
 “:ˆØ×"Ñ"Ó$ˆØ�‰�g˜}Ô-Ø×ÑÓ Ò(Ø×Ñ˜WÕ%ð )r   )ÚcategoryÚmessagec                 óê   — t        «       }|j                  «        | j                  | j                  g«      }| j	                  t        |«      d«       | j	                  |d   d   | j                  «       y)zV
        L{Platform.isWinNT} is deprecated in favor of L{platform.isWindows}.
        é   r   r=   N)r   r*   ÚflushWarningsÚtest_isWinNTDeprecatedr   ÚlenÚisWinNTDeprecationMessage)r   r&   Úwarningss      r   rA   z$PlatformTests.test_isWinNTDeprecated`   sc   € ô “:ˆØ×ÑÔØ×%Ñ% t×'BÑ'BÐ&CÓDˆØ×Ñœ˜X›¨Ô*Ø×Ñ˜ !™ YÑ/°×1OÑ1OÕPr   c                 óÖ   — 	 t        d«       | j                  t        «       j                  «       «       y# t        $ r* | j                  t        «       j                  «       «       Y yw xY w)z„
        L{Platform.supportsThreads} returns C{True} if threads can be created in
        this runtime, C{False} otherwise.
        Ú	threadingN)r   r#   r   ÚsupportsThreadsÚImportErrorr,   ©r   s    r   Útest_supportsThreadsz"PlatformTests.test_supportsThreadsj   sR   € ð	:Ü˜Ô$ð �O‰OœH›J×6Ñ6Ó8Õ9øô ò 	;Ø×ÑœX›Z×7Ñ7Ó9Ö:ð	;ús   ‚5 µ0A(Á'A(r   )r   r   r   r   rC   r'   r.   r2   r7   r;   ÚSUPRESSÚDeprecationWarningr   rA   rJ   r   r   r   r!   r!      sP   „ ñð
	Fð ó
,ó	2ó:ó>ó	&ñ 	Ø'Ø-ô	
ð€LÔóQô:r   r!   c                   ó(   — e Zd ZdZdd„Zdd„Zdd„Zy)ÚForeignPlatformTestszD
    Tests for L{Platform} based overridden initializer values.
    Nc                 óL  — | j                  t        d«      j                  «       d«       | j                  t        d«      j                  «       d«       | j                  t        d«      j                  «       d«       | j                  t        d«      j                  «       d«       y)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.
        Úntr9   Úcer0   ÚjavaN)r   r   r1   rI   s    r   Útest_getTypez!ForeignPlatformTests.test_getType   sz   € ð 	×Ñœ $›×/Ñ/Ó1°7Ô;Ø×Ñœ $›×/Ñ/Ó1°7Ô;Ø×Ñœ 'Ó*×2Ñ2Ó4°gÔ>Ø×Ñœ &Ó)×1Ñ1Ó3°VÕ<r   c                 óú   — | j                  t        dd«      j                  «       «       | j                  t        dd«      j                  «       «       | j                  t        dd«      j                  «       «       y)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Úlinux2r9   )r#   r   r-   r,   rI   s    r   Útest_isMacOSXz"ForeignPlatformTests.test_isMacOSXŠ   s\   € ð 	�‰œ  xÓ0×9Ñ9Ó;Ô<Ø×Ñœ $¨Ó1×:Ñ:Ó<Ô=Ø×Ñœ $¨Ó0×9Ñ9Ó;Õ<r   c                 óž  — | j                  t        dd«      j                  «       «       | j                  t        dd«      j                  «       «       | j                  t        dd«      j                  «       «       | j                  t        dd«      j                  «       «       | j                  t        dd«      j                  «       «       y)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.
        NrU   r4   rV   Úlinux3r9   )r,   r   r5   r#   rI   s    r   Útest_isLinuxz!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   rS   rW   rZ   r   r   r   rN   rN   z   s   „ ñó	=ó=ô
<r   rN   c                   ó0   — e Zd ZdZdd„Zdd„Zdd„Zdd„Zy)ÚDockerPlatformTestsz@
    Tests for L{twisted.python.runtime.Platform.isDocker}.
    Nc                 óZ   — t        dd«      }| j                  |j                  «       «       y)zV
        If the platform is not Linux, C{isDocker()} always returns L{False}.
        Nr9   ©r   r,   ÚisDockerr%   s     r   Útest_noChecksOnLinuxz(DockerPlatformTests.test_noChecksOnLinux¦   s'   € ô ˜D 'Ó*ˆØ×Ñ˜×*Ñ*Ó,Õ-r   c                 ó^   — t        dd«      }| j                  |j                  d¬«      «       y)zƒ
        If the platform is Linux, and the cgroups file in C{/proc} does not
        exist, C{isDocker()} returns L{False}
        Nr4   Úfakepath©Ú_initCGroupLocationr^   r%   s     r   Útest_noCGroupsz"DockerPlatformTests.test_noCGroups­   s,   € ô
 ˜D 'Ó*ˆØ×Ñ˜×*Ñ*¸zÐ*ÓJÕKr   c                 óâ   — | j                  «       }t        |d«      5 }|j                  d«       ddd«       t        dd«      }| j	                  |j                  |¬«      «       y# 1 sw Y   Œ7xY w)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/104155a6453cb67590027e397dc90fc25a06a7508403c797bc89ea43adf8d35fNr4   rc   )ÚmktempÚopenÚwriter   r#   r_   ©r   ÚcgroupsFileÚfr&   s       r   Útest_cgroupsSuggestsDockerz.DockerPlatformTests.test_cgroupsSuggestsDockerµ   sj   € ð —k‘k“mˆÜ�+˜tÓ$ð 	¨à�G‰Gð	Uô÷	ô ˜D 'Ó*ˆØ�‰˜×)Ñ)¸kÐ)ÓJÕK÷!	ð 	úó   �A%Á%A.c                 óâ   — | j                  «       }t        |d«      5 }|j                  d«       ddd«       t        dd«      }| j	                  |j                  |¬«      «       y# 1 sw Y   Œ7xY w)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}.
        rg   sy   9:perf_event:/
8:blkio:/
7:net_cls:/
6:freezer:/
5:devices:/
4:memory:/
3:cpuacct,cpu:/
2:cpuset:/
1:name=systemd:/systemNr4   rc   )rh   ri   rj   r   r,   r_   rk   s       r   Útest_cgroupsSuggestsRealSystemz2DockerPlatformTests.test_cgroupsSuggestsRealSystemÎ   sk   € ð —k‘k“mˆÜ�+˜tÓ$ð 	¨à�G‰Gðô
÷	ô ˜D 'Ó*ˆØ×Ñ˜×*Ñ*¸{Ð*ÓKÕL÷	ð 	úro   r   )r   r   r   r   r`   re   rn   rq   r   r   r   r\   r\   ¡   s   „ ñó.óLóLô2Mr   r\   )r   r   Útwisted.python.reflectr   Útwisted.python.runtimer   r   Útwisted.trial.unittestr   Útwisted.trial.utilr   rK   r	   r!   rN   r\   r   r   r   ú<module>rv      sW   ðñó
 å .ß ?Ý 6Ý 2ô?Ð,ô ?ôX:Ð'ô X:ôv$<Ð.ô $<ôNCMÐ-õ CMr   