
    tf                         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dS )z&
Tests for L{twisted.python.runtime}.
    N)namedModule)PlatformshortPythonVersion)SynchronousTestCase)suppressc                       e Zd ZdZddZdS )PythonVersionTestsz.
    Tests the shortPythonVersion method.
    returnNc                     t                                          d          }t          d          D ];}|                     t	          ||                   t
          j        |                    <dS )zE
        Verify if the Python version is returned correctly.
        .   N)r   splitrangeassertEqualintsysversion_info)selfveris      _/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/python/test/test_runtime.pytest_shortPythonVersionz*PythonVersionTests.test_shortPythonVersion   sg     !""((--q 	? 	?ASQ[[#*:1*=>>>>	? 	?    r
   N)__name__
__module____qualname____doc__r    r   r   r	   r	      s2         ? ? ? ? ? ?r   r	   c                   t    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dS )PlatformTestsz8
    Tests for the default L{Platform} initializer.
    zgtwisted.python.runtime.Platform.isWinNT was deprecated in Twisted 13.0. Use Platform.isWindows instead.r
   Nc                 p    t                      }|                     |                                           dS )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)   s1    
 ::((**+++++r   c                 8   t                      }|                                rw|                     |                                           |                     |                                           |                     |                                           dS dS )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    
 :: 	2OOH,,..///OOH..00111X..0011111	2 	2r   c                     t                      }|                                r*|                     |                                d           dS dS )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<   sS    
 :: 	:X--//99999	: 	:r   c                     t                      }|                                r4|                     t          j                            d                     dS dS )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   sS    
 :: 	>OOCL33G<<=====	> 	>r   c                     t                      }|                                }|                     |d           |                                dk    r|                     |           dS dS )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        g          }|                     t          |          d           |                     |d         d         | j                   dS )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`   s|     ::%%t'B&CDDX***!Y/1OPPPPPr   c                    	 t          d           |                     t                                                                 dS # t          $ r7 |                     t                                                                 Y dS 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   s    	:$$$ OOHJJ668899999  	; 	; 	;XZZ7799::::::	;s   A =BBr   )r   r   r   r   rC   r'   r.   r2   r7   r;   SUPRESSDeprecationWarningr   rA   rJ   r   r   r   r!   r!      s         
	F 
, , , ,	2 	2 	2 	2: : : :> > > >	& 	& 	& 	& 	'-	
 	
 	
LQ Q Q Q: : : : : :r   r!   c                   *    e Zd ZdZddZddZddZdS )ForeignPlatformTestszD
    Tests for L{Platform} based overridden initializer values.
    r
   Nc                    |                      t          d                                          d           |                      t          d                                          d           |                      t          d                                          d           |                      t          d                                          d           dS )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   s     	$//117;;;$//117;;;'**2244g>>>&))1133V<<<<<r   c                 D   |                      t          dd                                                     |                     t          dd                                                     |                     t          dd                                                     dS )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099;;<<<$11::<<===$0099;;<<<<<r   c                    |                      t          dd                                                     |                     t          dd                                                     |                     t          dd                                                     |                     t          dd                                                     |                      t          dd                                                     dS )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199;;<<<w//7799:::x0088::;;;x0088::;;;$0088::;;;;;r   r   )r   r   r   r   rS   rW   rZ   r   r   r   rN   rN   z   sZ         	= 	= 	= 	== = = =
< 
< 
< 
< 
< 
<r   rN   c                   2    e Zd ZdZddZddZddZddZdS )	DockerPlatformTestsz@
    Tests for L{twisted.python.runtime.Platform.isDocker}.
    r
   Nc                 t    t          dd          }|                     |                                           dS )zV
        If the platform is not Linux, C{isDocker()} always returns L{False}.
        Nr9   r   r,   isDockerr%   s     r   test_noChecksOnLinuxz(DockerPlatformTests.test_noChecksOnLinux   s9     D'****,,-----r   c                 x    t          dd          }|                     |                    d                     dS )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JKKKKKr   c                    |                                  }t          |d          5 }|                    d           ddd           n# 1 swxY w Y   t          dd          }|                     |                    |                     dS )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   s     kkmm+t$$ 	GG	U  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 D'**))k)JJKKKKK   AAAc                    |                                  }t          |d          5 }|                    d           ddd           n# 1 swxY w Y   t          dd          }|                     |                    |                     dS )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   s     kkmm+t$$ 	GG
 
 
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 D'****{*KKLLLLLro   r   )r   r   r   r   r`   re   rn   rq   r   r   r   r\   r\      s|         . . . .L L L LL L L L2M M M M M 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      s<   
 


 . . . . . . ? ? ? ? ? ? ? ? 6 6 6 6 6 6 2 2 2 2 2 2? ? ? ? ?, ? ? ?X: X: X: X: X:' X: X: X:v$< $< $< $< $<. $< $< $<NCM CM CM CM CM- CM CM CM CM CMr   