HEX
Server: nginx/1.24.0
System: Linux localhost 5.15.0-46-generic #49-Ubuntu SMP Thu Aug 4 18:03:25 UTC 2022 x86_64
User: www (1000)
PHP: 8.3.27
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: //usr/lib/python3/dist-packages/twisted/python/test/__pycache__/test_systemd.cpython-310.pyc
o

�b��@szdZddlZddlmZddlmZGdd�d�ZGdd�d�ZGd	d
�d
�ZGdd�deee�Z	Gd
d�deee�Z
dS)z&
Tests for L{twisted.python.systemd}.
�N)�	ListenFDs)�TestCasec@� eZdZdZdd�Zdd�ZdS)�InheritedDescriptorsMixinz�
    Mixin for a L{TestCase} subclass which defines test methods for some kind of
    systemd sd-daemon class.  In particular, it defines tests for a
    C{inheritedDescriptors} method.
    cCs$|�dd�}|�gd�|���dS)z�
        C{inheritedDescriptors} returns a list of integers giving the file
        descriptors which were inherited from systemd.
        ��)r��	N��	getDaemon�assertEqual�inheritedDescriptors��self�sddaemon�r�B/usr/lib/python3/dist-packages/twisted/python/test/test_systemd.py�test_inheritedDescriptorssz3InheritedDescriptorsMixin.test_inheritedDescriptorscCs$|�dd�}|�|��|���dS)zW
        Any subsequent calls to C{inheritedDescriptors} return the same list.
        rrNr
rrrr�
test_repeateds�z'InheritedDescriptorsMixin.test_repeatedN)�__name__�
__module__�__qualname__�__doc__rrrrrrrsrc@seZdZdZdd�ZdS)�MemoryOnlyMixinz�
    Mixin for a L{TestCase} subclass which creates creating a fake, in-memory
    implementation of C{inheritedDescriptors}.  This provides verification that
    the fake behaves in a compatible way with the real implementation.
    cCstt|||��S)a
        Invent C{count} new I{file descriptors} (actually integers, attached to
        no real file description), starting at C{start}.  Construct and return a
        new L{ListenFDs} which will claim those integers represent inherited
        file descriptors.
        )r�range)r�start�countrrrr/szMemoryOnlyMixin.getDaemonN)rrrrrrrrrr(src@r)�EnvironmentMixinaV
    Mixin for a L{TestCase} subclass which creates a real implementation of
    C{inheritedDescriptors} which is based on the environment variables set by
    systemd.  To facilitate testing, this mixin will also create a fake
    environment dictionary and add keys to it to make it look as if some
    descriptors have been inherited.
    cCs&tj��}t|�|d<t|�|d<|S)z�
        Create a copy of the process environment and add I{LISTEN_FDS} and
        I{LISTEN_PID} (the environment variables set by systemd) to it.
        �
LISTEN_FDS�
LISTEN_PID)�os�environ�copy�str)rr�pid�resultrrr�initializeEnvironmentBs
z&EnvironmentMixin.initializeEnvironmentcCs|�|t���}tj||d�S)a

        Create a new L{ListenFDs} instance, initialized with a fake environment
        dictionary which will be set up as systemd would have set it up if
        C{count} descriptors were being inherited.  The descriptors will also
        start at C{start}.
        )r!r)r&r �getpidr�fromEnvironment)rrr�fakeEnvironmentrrrrLszEnvironmentMixin.getDaemonN)rrrrr&rrrrrr9s
rc@seZdZdZdS)�MemoryOnlyTestszb
    Apply tests to L{ListenFDs}, explicitly constructed with some fake file
    descriptors.
    N)rrrrrrrrr*Wsr*c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�EnvironmentTestszV
    Apply tests to L{ListenFDs}, constructed based on an environment dictionary.
    cCsV|�dt���}tj|d�}tj|d�}|�ttdd��|���|�g|���dS)zV
        Only a single L{Environment} can extract inherited file descriptors.
        r�r!�N)	r&r r'rr(r�listrr
)rr)�first�secondrrr�test_secondEnvironmentcs
z'EnvironmentTests.test_secondEnvironmentcCs4|�dt��d�}tj|d�}|�g|���dS)z�
        If the current process PID does not match the PID in the environment, no
        inherited descriptors are reported.
        r�r,N�r&r r'rr(rr
�rr)rrrr�test_mismatchedPIDmsz#EnvironmentTests.test_mismatchedPIDcC�6|�dt���}|d=tj|d�}|�g|���dS)zz
        If the I{LISTEN_PID} environment variable is not present, no inherited
        descriptors are reported.
        rrr,Nr3r4rrr�test_missingPIDVariablev�z(EnvironmentTests.test_missingPIDVariablecCs,|�dd�}tj|d�}|�g|���dS)z�
        If the I{LISTEN_PID} environment variable is set to a string that cannot
        be parsed as an integer, no inherited descriptors are reported.
        r�hello, worldr,N)r&rr(rr
r4rrr�test_nonIntegerPIDVariable�sz+EnvironmentTests.test_nonIntegerPIDVariablecCr6)zz
        If the I{LISTEN_FDS} environment variable is not present, no inherited
        descriptors are reported.
        rrr,Nr3r4rrr�test_missingFDSVariable�r8z(EnvironmentTests.test_missingFDSVariablecCs0|�dt���}tj|d�}|�g|���dS)z�
        If the I{LISTEN_FDS} environment variable is set to a string that cannot
        be parsed as an integer, no inherited descriptors are reported.
        r9r,Nr3r4rrr�test_nonIntegerFDSVariable�sz+EnvironmentTests.test_nonIntegerFDSVariablecCsB|�tdtt���dd��t��}|�ttdd��|�	��dS)z�
        If the process environment is not explicitly passed to
        L{Environment.__init__}, the real process environment dictionary is
        used.
        r!�5)rrrrN)
�patchr r#r'rr(rr.rr
rrrr�test_defaultEnviron�sz$EnvironmentTests.test_defaultEnvironN)rrrrr1r5r7r:r;r<r?rrrrr+^s
	
	
	r+)rr �twisted.python.systemdr�twisted.trial.unittestrrrrr*r+rrrr�<module>s