ó
    Ö›‘h±  ã                   ó²   • S r SSKrSSKJrJrJr  SSKJrJrJ	r	  SSK
Jr  SSKJrJrJr  SSKJr  SSKJr  S	S
KJr  S\S\S\\\4   4S jr " S S\5      rg)z&
Tests for L{twisted.python.systemd}.
é    N)ÚDictÚMappingÚSequence)Úassert_thatÚequal_toÚnot_)Úgiven)ÚdictionariesÚintegersÚlists)Ú	ListenFDs)ÚSynchronousTestCaseé   )ÚsystemdDescriptorNamesÚcountÚpidÚreturnc                 óä   • [         R                  R                  5       n[        U 5      US'   SR	                  [        U 5       Vs/ s H  o3 S3PM	     sn5      US'   [        U5      US'   U$ s  snf )a  
@param count: The number of file descriptors to indicate as inherited.

@param pid: The pid of the inheriting process to indicate.

@return: A copy of the current process environment with the I{systemd}
    file descriptor inheritance-related environment variables added to it.
Ú
LISTEN_FDSÚ:z.socketÚLISTEN_FDNAMESÚ
LISTEN_PID)ÚosÚenvironÚcopyÚstrÚjoinÚrange)r   r   ÚresultÚns       ÚdC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/python/test/test_systemd.pyÚbuildEnvironmentr"      sf   € ô �Z‰Z�_‰_Ó€FÜ˜u›:€Fˆ<ÑØ"Ÿx™xÄÀeÄÓ(MÂ¸1¨3¨g«ÁÑ(MÓN€FÐÑÜ˜s›8€Fˆ<ÑØ€Mùò )Ns   ÁA-c            	       óv  • \ rS rSrSr\" \" \" 5       SSS95      S\\	   SS4S	 j5       r
SS
 jrSS jrSS jrSS jrSS jrSS jrSS jr\" \" \" SSS9SS95      S\\   SS4S j5       r\" \" \" 5       \" SS9SS95      S\\	\4   SS4S j5       r\" \" \" SSS9SS95      S\\   SS4S j5       rSrg)ÚListenFDsTestsé%   zN
Apply tests to L{ListenFDs}, constructed based on an environment dictionary.
r   é
   )Úmin_sizeÚmax_sizeÚnamesr   Nc                 ón  • [        U5      n[        [        [        R                  [        R                  U-   5      5      n[        R
                  " [        [        R                  " 5       5      [        U5      SR                  U5      S.5      n[        U[        [        U[        U5      5      5      5        g)aX  
The L{ListenFDs} and L{ListenFDs.fromEnvironment} constructors are
equivalent for their respective representations of the same
information.

@param names: The names of the file descriptors to represent as
    inherited in the test environment given to the parser.  The number
    of descriptors represented will equal the length of this list.
r   )r   r   r   N)ÚlenÚlistr   r   Ú_STARTÚfromEnvironmentr   r   Úgetpidr   r   r   Útuple)Úselfr)   ÚnumFDsÚdescriptorsÚfdss        r!   Útest_fromEnvironmentEquivalenceÚ.ListenFDsTests.test_fromEnvironmentEquivalence*   s€   € ô �U“ˆÜœ5¤×!1Ñ!1´9×3CÑ3CÀfÑ3LÓMÓNˆÜ×'Ò'ä!¤"§)¢)£+Ó.Ü! &›kØ"%§(¡(¨5£/ñó
ˆô 	�Cœ¤)¨K¼¸u»Ó"FÓGÕHó    c           	      óü   • U R                  [        S[        S[        R                  " 5       5      5        [        R
                  " 5       nU R                  [        [        SS5      5      UR                  5       5        g)z‡
If the process environment is not explicitly passed to
L{ListenFDs.fromEnvironment}, the real process environment dictionary
is used.
r   é   é   é   N)
Úpatchr   r"   r/   r   r.   ÚassertEqualr,   r   ÚinheritedDescriptors)r1   Úsddaemons     r!   Útest_defaultEnvironÚ"ListenFDsTests.test_defaultEnviron@   sT   € ð 	�
‰
”2�yÔ"2°1´b·i²i³kÓ"BÔCÜ×,Ò,Ó.ˆØ×Ñœœe A u›oÓ.°×0MÑ0MÓ0OÕPr7   c                 ó8  • [        S[        R                  " 5       5      n[        R                  " US9n[        R                  " US9nU R                  [        [        SS5      5      UR                  5       5        U R                  / UR                  5       5        g)zã
L{ListenFDs.fromEnvironment} removes information about the
inherited file descriptors from the environment mapping so that the
same inherited file descriptors cannot be handled repeatedly from
multiple L{ListenFDs} instances.
r:   ©r   é   N)	r"   r   r/   r   r.   r=   r,   r   r>   )r1   ÚenvÚfirstÚseconds       r!   Útest_secondEnvironmentÚ%ListenFDsTests.test_secondEnvironmentJ   ss   € ô ˜q¤"§)¢)£+Ó.ˆÜ×)Ò)°#Ñ6ˆÜ×*Ò*°3Ñ7ˆØ×Ñœœe A q›kÓ*¨E×,FÑ,FÓ,HÔIØ×Ñ˜˜V×8Ñ8Ó:Õ;r7   c                 ó°   • [        S[        R                  " 5       S-   5      n[        R                  " US9nU R                  / UR                  5       5        g)a&  
If the current process PID does not match the PID in the
environment then the systemd variables in the environment were set for
a different process (perhaps our parent) and the inherited descriptors
are not intended for this process so L{ListenFDs.inheritedDescriptors}
returns an empty list.
r:   r   rC   N©r"   r   r/   r   r.   r=   r>   ©r1   rE   r?   s      r!   Útest_mismatchedPIDÚ!ListenFDsTests.test_mismatchedPIDW   sC   € ô ˜q¤"§)¢)£+°¡/Ó2ˆÜ×,Ò,°SÑ9ˆØ×Ñ˜˜X×:Ñ:Ó<Õ=r7   c                 ó°   • [        S[        R                  " 5       5      nUS	 [        R                  " US9nU R                  / UR                  5       5        g)zÑ
If the I{LISTEN_PID} environment variable is not present then
there is no clear indication that any file descriptors were inherited
by this process so L{ListenFDs.inheritedDescriptors} returns an empty
list.
r:   r   rC   NrK   rL   s      r!   Útest_missingPIDVariableÚ&ListenFDsTests.test_missingPIDVariablec   sG   € ô ˜q¤"§)¢)£+Ó.ˆØ�ÐÜ×,Ò,°SÑ9ˆØ×Ñ˜˜X×:Ñ:Ó<Õ=r7   c                 ó„   • [        SS5      n[        R                  " US9nU R                  / UR	                  5       5        g)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, worldrC   N)r"   r   r.   r=   r>   rL   s      r!   Útest_nonIntegerPIDVariableÚ)ListenFDsTests.test_nonIntegerPIDVariableo   s9   € ô
 ˜q .Ó1ˆÜ×,Ò,°SÑ9ˆØ×Ñ˜˜X×:Ñ:Ó<Õ=r7   c                 ó¶   • [        S[        R                  " 5       5      nUS	 US	 [        R                  " US9nU R                  / UR                  5       5        g)zz
If the I{LISTEN_FDS} and I{LISTEN_FDNAMES} environment variables
are not present, no inherited descriptors are reported.
r:   r   r   rC   NrK   rL   s      r!   Útest_missingFDSVariableÚ&ListenFDsTests.test_missingFDSVariablex   sP   € ô
 ˜q¤"§)¢)£+Ó.ˆØ�ÐØÐ Ð!Ü×,Ò,°SÑ9ˆØ×Ñ˜˜X×:Ñ:Ó<Õ=r7   c                 ó´   • [        S[        R                  " 5       5      nSUS'   [        R                  " US9nU R                  / UR                  5       5        g)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.
r:   rS   r   rC   NrK   rL   s      r!   Útest_nonIntegerFDSVariableÚ)ListenFDsTests.test_nonIntegerFDSVariableƒ   sI   € ô
 ˜q¤"§)¢)£+Ó.ˆØ*ˆˆLÑÜ×,Ò,°SÑ9ˆØ×Ñ˜˜X×:Ñ:Ó<Õ=r7   )Ú	min_valueÚ	max_valueT)Úuniquer3   c                 óô   • [        [        [        U5      5      n[        X5      nUR	                  5       n[        U[        U5      5        UR                  S5        [        U[        [        U5      5      5        g)zU
L{ListenFDs.inheritedDescriptors} returns a copy of the inherited
descriptors list.
r   N)	r0   Úmapr   r   r>   r   r   Úappendr   )r1   r3   r)   r4   ÚfdsCopys        r!   Útest_inheritedDescriptorsÚ(ListenFDsTests.test_inheritedDescriptors�   s\   € ô ”cœ#˜{Ó+Ó,ˆÜ˜Ó+ˆØ×*Ñ*Ó,ˆÜ�K¤¨'Ó!2Ô3Ø�‰�qÔÜ�K¤¤h¨wÓ&7Ó!8Õ9r7   )r\   )r(   Úexpectedc                 ó  • [        UR                  5       5      nU VVs/ s H  u  p4UPM	     nnnU VVs/ s H  u  pFUPM	     nnn[        Xu5      n[        UR	                  5       [        U5      5        gs  snnf s  snnf )z»
L{ListenFDs.inheritedNamedDescriptors} returns a mapping from the
descriptor names to their integer values, with items formed by
pairwise combination of the input descriptors and names.
N)r,   Úitemsr   r   ÚinheritedNamedDescriptorsr   )	r1   re   rg   ÚnameÚ_r)   Úfdr3   r4   s	            r!   Útest_inheritedNamedDescriptorsÚ-ListenFDsTests.test_inheritedNamedDescriptorsš   sk   € ô �X—^‘^Ó%Ó&ˆÙ%*Ô+¢U™'˜$“¡UˆÑ+Ù',Ô-¢u™e˜a“r¡uˆÑ-Ü˜Ó+ˆÜ�C×1Ñ1Ó3´X¸hÓ5GÕHùó ,ùÛ-s
   ŸA5µA;c                 ó  • [        [        [        U5      5      n[        X5      nU R	                  UR                  5       UR                  5       5        U R	                  UR                  5       UR                  5       5        g)zh
Any subsequent calls to C{inheritedDescriptors} and
C{inheritedNamedDescriptors} return the same list.
N)r0   r`   r   r   r=   r>   rh   )r1   r3   r)   r?   s       r!   Útest_repeatedÚListenFDsTests.test_repeated§   sk   € ô ”cœ#˜{Ó+Ó,ˆÜ˜[Ó0ˆØ×ÑØ×)Ñ)Ó+¨X×-JÑ-JÓ-Lô	
ð 	×ÑØ×.Ñ.Ó0°(×2TÑ2TÓ2Võ	
r7   © )r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r	   r   r   r   r   r5   r@   rH   rM   rP   rT   rW   rZ   r   Úintrc   r
   r   rl   ro   Ú__static_attributes__rq   r7   r!   r$   r$   %   s$  † ññ ‰5Ñ'Ó)°AÀÑCÓDðI°X¸c±]ð IÀtó Ió EðIô*Qô<ô
>ô
>ô>ô	>ô>ñ ‰5‘ A°Ñ4¸TÑBÓCð
:°X¸c±]ð 
:Àtó 
:ó Dð
:ñ ‰<Ñ.Ó0±(ÀQÑ2GÐRTÑUÓVð
I°w¸sÀC¸xÑ7Hð 
IÈTó 
Ió Wð
Iñ ‰5‘ A°Ñ4¸TÑBÓCð
¨°#©ð 
¸4ó 
ó Dó
r7   r$   )rv   r   Útypingr   r   r   Úhamcrestr   r   r   Ú
hypothesisr	   Úhypothesis.strategiesr
   r   r   Útwisted.python.systemdr   Útwisted.trial.unittestr   Ú
strategiesr   rw   Úobjectr   r"   r$   rq   r7   r!   Ú<module>r�      s^   ðñó
 
ß *Ñ *ç 0Ñ 0Ý ß ?Ñ ?å ,Ý 6Ý .ð˜Cð  fð °°c¸3°h±ô ô O
Ð(õ O
r7   