HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/twisted/python/test/__pycache__/test_runtime.cpython-38.pyc
U


W[��@s�dZddlmZmZddlZddlmZddlmZ	ddl
mZddlm
Z
mZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�ZGdd�de�ZdS)z&
Tests for L{twisted.python.runtime}.
�)�division�absolute_importN)�namedModule)�suppress)�SynchronousTestCase)�Platform�shortPythonVersionc@seZdZdZdd�ZdS)�PythonVersionTestsz.
    Tests the shortPythonVersion method.
    cCs8t��d�}td�D]}|�t||�tj|�qdS)zE
        Verify if the Python version is returned correctly.
        �.�N)r�split�range�assertEqual�int�sys�version_info)�selfZver�i�r�B/usr/lib/python3/dist-packages/twisted/python/test/test_runtime.py�test_shortPythonVersionsz*PythonVersionTests.test_shortPythonVersionN)�__name__�
__module__�__qualname__�__doc__rrrrrr	sr	c@s\eZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	e
eed
�ge	_dd�Z
dd�ZdS)�
PlatformTestsz8
    Tests for the default L{Platform} initializer.
    zgtwisted.python.runtime.Platform.isWinNT was deprecated in Twisted 13.0. Use Platform.isWindows instead.cCst�}|�|���dS)z�
        L{Platform.isKnown} returns a boolean indicating whether this is one of
        the L{runtime.knownPlatforms}.
        N)r�
assertTrueZisKnown�r�platformrrr�test_isKnown+szPlatformTests.test_isKnowncCs<t�}|��r8|�|���|�|���|�|���dS)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)rZisVistar�isWinNTZ	isWindows�assertFalse�isMacOSXrrrr�test_isVistaConsistency4s
z%PlatformTests.test_isVistaConsistencycCs"t�}|��r|�|��d�dS)zq
        L{Platform.isMacOSX} can only return C{True} if L{Platform.getType}
        returns C{'posix'}.
        �posixN)rr"r�getTyperrrr�test_isMacOSXConsistency@sz&PlatformTests.test_isMacOSXConsistencycCs$t�}|��r |�tj�d��dS)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�isLinuxrrr�
startswithrrrr�test_isLinuxConsistencyJsz%PlatformTests.test_isLinuxConsistencycCs4t�}|��}|�|d�|��dkr0|�|�dS)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)rr ZassertInr%r!)rrr rrr�test_isWinNTTs
zPlatformTests.test_isWinNT)�category�messagecCsFt�}|��|�|jg�}|�t|�d�|�|dd|j�dS)zV
        L{Platform.isWinNT} is deprecated in favor of L{platform.isWindows}.
        �rr.N)rr Z
flushWarnings�test_isWinNTDeprecatedr�len�isWinNTDeprecationMessage)rr�warningsrrrr0cs
�z$PlatformTests.test_isWinNTDeprecatedcCsFztd�Wn$tk
r0|�t����YnX|�t����dS)z�
        L{Platform.supportsThreads} returns C{True} if threads can be created in
        this runtime, C{False} otherwise.
        Z	threadingN)r�ImportErrorr!rZsupportsThreadsr�rrrr�test_supportsThreadsos
z"PlatformTests.test_supportsThreadsN)rrrrr2rr#r&r*r,�SUPRESS�DeprecationWarningrr0r6rrrrr"s	

�
rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�ForeignPlatformTestszD
    Tests for L{Platform} based overridden initializer values.
    cCsT|�td���d�|�td���d�|�td���d�|�td���d�dS)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.
        �ntr+Zcer$�javaN)rrr%r5rrr�test_getType�sz!ForeignPlatformTests.test_getTypecCs@|�tdd����|�tdd����|�tdd����dS)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�linux2r+)rrr"r!r5rrr�
test_isMacOSX�sz"ForeignPlatformTests.test_isMacOSXcCsh|�tdd����|�tdd����|�tdd����|�tdd����|�tdd����dS)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.
        Nr=r'r>Zlinux3r+)r!rr(rr5rrr�test_isLinux�s
z!ForeignPlatformTests.test_isLinuxN)rrrrr<r?r@rrrrr9�sr9c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�DockerPlatformTestsz@
    Tests for L{twisted.python.runtime.Platform.isDocker}.
    cCstdd�}|�|���dS)zV
        If the platform is not Linux, C{isDocker()} always returns L{False}.
        Nr+�rr!�isDockerrrrr�test_noChecksOnLinux�s
z(DockerPlatformTests.test_noChecksOnLinuxcCs tdd�}|�|jdd��dS)z�
        If the platform is Linux, and the cgroups file in C{/proc} does not
        exist, C{isDocker()} returns L{False}
        Nr'Zfakepath�Z_initCGroupLocationrBrrrr�test_noCGroups�s
z"DockerPlatformTests.test_noCGroupsc	CsH|��}t|d��}|�d�W5QRXtdd�}|�|j|d��dS)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}.
        �wbsd10: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'rE)�mktemp�open�writerrrC�rZcgroupsFile�frrrr�test_cgroupsSuggestsDocker�s

z.DockerPlatformTests.test_cgroupsSuggestsDockerc	CsH|��}t|d��}|�d�W5QRXtdd�}|�|j|d��dS)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}.
        rGsy9:perf_event:/
8:blkio:/
7:net_cls:/
6:freezer:/
5:devices:/
4:memory:/
3:cpuacct,cpu:/
2:cpuset:/
1:name=systemd:/systemNr'rE)rHrIrJrr!rCrKrrr�test_cgroupsSuggestsRealSystem�s


z2DockerPlatformTests.test_cgroupsSuggestsRealSystemN)rrrrrDrFrMrNrrrrrA�s
	rA)rZ
__future__rrrZtwisted.python.reflectrZtwisted.trial.utilrr7Ztwisted.trial.unittestrZtwisted.python.runtimerrr	rr9rArrrr�<module>s^*