+
    Dfj$                        R t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
Ht ^ RIHtHt ^ RIHt ^ RIHt  ! R	 R
]4      t ! R R]4      t ! R R]4      t ! R R]4      t]! 4       P1                  ]P3                  4       4       ]! 4       P1                  ]P3                  4       4       ]! 4       P1                  ]P3                  4       4       ]! 4       P1                  ]P3                  4       4       R# )aD  
Tests for implementations of L{IReactorSocket}.

Generally only tests for failure cases are found here.  Success cases for
this interface are tested elsewhere.  For example, the success case for
I{AF_INET} is in L{twisted.internet.test.test_tcp}, since that case should
behave exactly the same as L{IReactorTCP.listenTCP}.
N)verify)UnsupportedAddressFamily)IReactorSocket)DatagramProtocolServerFactory)ReactorBuilderneedsRunningReactor)err)platformc                   0   a  ] tR t^t o Rt].tR tRtV t	R# )&IReactorSocketVerificationTestsBuildera#  
Builder for testing L{IReactorSocket} implementations for required
methods and method signatures.

L{ReactorBuilder} already runs L{IReactorSocket.providedBy} to
ensure that these tests will only be run on reactor classes that
claim to implement L{IReactorSocket}.

These tests ensure that reactors which claim to provide the
L{IReactorSocket} interface actually have all the required methods
and that those methods have the expected number of arguments.

These tests will be skipped for reactors which do not claim to
provide L{IReactorSocket}.
c                z    V P                  4       pV P                  \        P                  ! \        V4      4       R# )zN
The reactor instance returned by C{buildReactor} provides
L{IReactorSocket}.
N)buildReactor
assertTruer   verifyObjectr   )selfreactors   & C/usr/lib/python3/dist-packages/twisted/internet/test/test_socket.pytest_provider4IReactorSocketVerificationTestsBuilder.test_provider-   s+    
 ##%++NGDE     N)
__name__
__module____qualname____firstlineno____doc__r   requiredInterfacesr   __static_attributes____classdictcell____classdict__s   @r   r   r      s!       ))F Fr   r   c                   <   a  ] tR t^6t o Rt].tR tR tR t	Rt
V tR# )!AdoptStreamPortErrorsTestsBuildera[  
Builder for testing L{IReactorSocket.adoptStreamPort} implementations.

Generally only tests for failure cases are found here.  Success cases for
this interface are tested elsewhere.  For example, the success case for
I{AF_INET} is in L{twisted.internet.test.test_tcp}, since that case should
behave exactly the same as L{IReactorTCP.listenTCP}.
c                   V P                  4       p\        P                  ! 4       pVP                  4       pVP                  4        V P	                  \        P
                  VP                  V\        P                  \        4       4      p\        P                  ! 4       '       d4   V P                  VP                  ^ ,          \        P                  4       R# V P                  VP                  ^ ,          \        P                  4       R# )z
An implementation of L{IReactorSocket.adoptStreamPort} raises
L{socket.error} if passed an integer which is not associated with a
socket.
N)r   socketfilenocloseassertRaiseserroradoptStreamPortAF_INETr   r
   	isWindowsassertEqualargserrnoWSAENOTSOCKEBADFr   r   prober&   excs   &    r   test_invalidDescriptor8AdoptStreamPortErrorsTestsBuilder.test_invalidDescriptorB   s     ##%LL##NNO
 SXXa[%*;*;<SXXa[%++6r   c                @   V P                  4       p\        P                  ! 4       pVP                  R4       VP                  ^4       V P	                  VP
                  4       RpV P                  \        VP                  VP                  4       V\        4       4       R# )z
An implementation of L{IReactorSocket.adoptStreamPort} raises
L{UnsupportedAddressFamily} if passed an address family it does not
support.
Nz	127.0.0.1      )r   r%   bindlisten
addCleanupr'   r(   r   r*   r&   r   r   r   port	arbitrarys   &   r   test_invalidAddressFamily;AdoptStreamPortErrorsTestsBuilder.test_invalidAddressFamilyZ   su     ##%}}		"#A

#	$##KKMO	
r   c                  a aaa S P                  4       o\        P                  ! 4       oS P                  SP                  4       SP	                  R4       SP                  ^4       SP                  R4       SP                  SP                  4       SP                  \        4       4      pVP                  4       oVV 3R lpSP                  V4       SP                  \        R4       \        SVV3R l4       SP!                  4        R# )a	  
When the L{IListeningPort} returned by
L{IReactorSocket.adoptStreamPort} is stopped using
C{stopListening}, the underlying socket is closed but not
shutdown.  This allows another process which still has a
reference to it to continue accepting connections over it.
Fc                 Z  < SP                  \        P                  SP                  4      p\        P
                  ! 4       '       d4   SP                  VP                  ^ ,          \        P                  4       R# SP                  VP                  ^ ,          \        P                  4       R# )r9   N)r(   r%   r)   acceptr
   r,   r-   r.   r/   WSAEWOULDBLOCKEAGAINignoredr4   
portSocketr   s   & r   stoppedFAdoptStreamPortErrorsTestsBuilder.test_stopOnlyCloses.<locals>.stopped   sj     ##FLL*2C2CDC!!##  !e.B.BC  !ell;r   z"Failed to accept on original port.c                  .   < S P                  V3R  l4      # )c                 $   < SP                  4       # NstoprI   r   s   &r   <lambda>YAdoptStreamPortErrorsTestsBuilder.test_stopOnlyCloses.<locals>.<lambda>.<locals>.<lambda>       7<<>r   addCallbackdr   s   r   rS   GAdoptStreamPortErrorsTestsBuilder.test_stopOnlyCloses.<locals>.<lambda>       Q]]+IJr   Nr8   )r   r%   r=   r'   r;   r<   setblockingr*   r&   familyr   stopListeningrW   
addErrbackr	   r   runr   r?   rK   rY   rJ   r   s   f  @@@r   test_stopOnlyCloses5AdoptStreamPortErrorsTestsBuilder.test_stopOnlyClosesq   s     ##%]]_

(()()!u% &&!2!2MO
  	< 	
g	S>?J	
 	r   r   Nr   r   r   r   r   r   r   r5   rA   rb   r   r   r    s   @r   r#   r#   6   s)      ))70
.( (r   r#   c                   0   a  ] tR t^t o Rt].tR tRtV t	R# )'AdoptStreamConnectionErrorsTestsBuilderaa  
Builder for testing L{IReactorSocket.adoptStreamConnection}
implementations.

Generally only tests for failure cases are found here.  Success cases for
this interface are tested elsewhere.  For example, the success case for
I{AF_INET} is in L{twisted.internet.test.test_tcp}, since that case should
behave exactly the same as L{IReactorTCP.listenTCP}.
c                    V P                  4       p\        P                  ! 4       pV P                  VP                  4       RpV P	                  \
        VP                  VP                  4       V\        4       4       R# )z
An implementation of L{IReactorSocket.adoptStreamConnection} raises
L{UnsupportedAddressFamily} if passed an address family it does not
support.
Nr:   )	r   r%   r=   r'   r(   r   adoptStreamConnectionr&   r   )r   r   
connectionr@   s   &   r   rA   AAdoptStreamConnectionErrorsTestsBuilder.test_invalidAddressFamily   sb     ##%]]_

(()	$))O	
r   r   N)
r   r   r   r   r   r   r   rA   r   r   r    s   @r   rf   rf      s      ))
 
r   rf   c                   <   a  ] tR t^t o Rt].tR tR tR t	Rt
V tR# )#AdoptDatagramPortErrorsTestsBuilderzJ
Builder for testing L{IReactorSocket.adoptDatagramPort} implementations.
c                   V P                  4       p\        P                  ! 4       pVP                  4       pVP                  4        V P	                  \        P
                  VP                  V\        P                  \        4       4      p\        P                  ! 4       '       d4   V P                  VP                  ^ ,          \        P                  4       R# V P                  VP                  ^ ,          \        P                  4       R# )z
An implementation of L{IReactorSocket.adoptDatagramPort} raises
L{socket.error} if passed an integer which is not associated with a
socket.
N)r   r%   r&   r'   r(   r)   adoptDatagramPortr+   r   r
   r,   r-   r.   r/   r0   r1   r2   s   &    r   r5   :AdoptDatagramPortErrorsTestsBuilder.test_invalidDescriptor   s     ##%LL%%NN
 SXXa[%*;*;<SXXa[%++6r   c                8   V P                  4       p\        P                  ! \        P                  \        P                  4      pV P	                  VP
                  4       RpV P                  \        VP                  VP                  4       V\        4       4       R# )z
An implementation of L{IReactorSocket.adoptDatagramPort} raises
L{UnsupportedAddressFamily} if passed an address family it does not
support.
Nr:   )r   r%   r+   
SOCK_DGRAMr=   r'   r(   r   rn   r&   r   r>   s   &   r   rA   =AdoptDatagramPortErrorsTestsBuilder.test_invalidAddressFamily   sm     ##%}}V^^V->->?

#	$%%KKM	
r   c                2  a aaa S P                  4       o\        P                  ! \        P                  \        P                  4      oS P	                  SP
                  4       SP                  R4       SP                  R4       SP                  SP                  4       SP                  \        4       4      pVP                  4       oVV 3R lpSP                  V4       SP                  \        R4       \!        SVV3R l4       SP#                  4        R# )a  
When the L{IListeningPort} returned by
L{IReactorSocket.adoptDatagramPort} is stopped using
C{stopListening}, the underlying socket is closed but not
shutdown.  This allows another process which still has a
reference to it to continue reading and writing to it.
Fc                 \  < SP                  \        P                  SP                  ^4      p\        P
                  ! 4       '       d4   SP                  VP                  ^ ,          \        P                  4       R# SP                  VP                  ^ ,          \        P                  4       R# )   N)r(   r%   r)   recvfromr
   r,   r-   r.   r/   rF   rG   rH   s   & r   rK   HAdoptDatagramPortErrorsTestsBuilder.test_stopOnlyCloses.<locals>.stopped	  sl     ##FLL*2E2EqIC!!##  !e.B.BC  !ell;r   z Failed to read on original port.c                  .   < S P                  V3R  l4      # )c                 $   < SP                  4       # rO   rP   rR   s   &r   rS   [AdoptDatagramPortErrorsTestsBuilder.test_stopOnlyCloses.<locals>.<lambda>.<locals>.<lambda>  rU   r   rV   rX   s   r   rS   IAdoptDatagramPortErrorsTestsBuilder.test_stopOnlyCloses.<locals>.<lambda>  r[   r   Nr8   )r   r%   r+   rq   r=   r'   r;   r\   rn   r&   r]   r   r^   rW   r_   r	   r   r`   ra   s   f  @@@r   rb   7AdoptDatagramPortErrorsTestsBuilder.test_stopOnlyCloses   s     ##%]]6>>63D3DE

(()()u% ((!2!24D4F
  	< 	
g	S<=J	
 	r   r   Nrd   r    s   @r   rl   rl      s)      ))70
*& &r   rl   )r   r/   r%   zope.interfacer   twisted.internet.errorr   twisted.internet.interfacesr   twisted.internet.protocolr   r   #twisted.internet.test.reactormixinsr   r   twisted.python.logr	   twisted.python.runtimer
   r   r#   rf   rl   globalsupdatemakeTestCaseClassesr   r   r   <module>r      s      ! ; 6 E S " +F^ F8c cL 
n  
FZ. Zz 	  7KKM N 	  2FFH I 	  8LLN O 	  4HHJ Kr   