
    Yfk&                        d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ d dl	m
Z
  G d de
j                  Z G d d	e
j                  Z G d
 de
j                  ZdS )    )annotationsN)Sequence)error)unittestc                     e Zd ZU dZg dej        g i fdej        dgi fdej        ddgi fdej        dd	 ej        d
          fi fdej        g i fdej        ddgi fdej	        g i fdej	        ddgi fdej
        g i fdej
        dgi fdej
        g ddifdej
        ddgi fdej        g i fdej        dgi fdej        ddgi fdej        g i fdej        g i fdej        g i fdej        g i fdej        g i fdej        g i fdej        g i fdej        g i fd ej        g i fd!ej        g i fd"ej        ddgi fd#ej        g i fd$ej        ddgi fd%ej        g i fd&ej        g i fd'ej        ddgi fd(ej        g i fd)ej        d*d+gi fd,ej        d-gi fd.ej        g i fd/ej        g d0d1ifd2ej        g d3d4ifd5ej        g i fd6ej        d*d7gi fd8ej        g i fd9ej        d:d;gi fZd<ed=<   dBd@Z dBdAZ!d-S )CStringificationTestsz6Test that the exceptions have useful stringifications.z*An error occurred binding to an interface.z/An error occurred binding to an interface: foo.fooz3An error occurred binding to an interface: foo bar.barz"Couldn't listen on eth0:4242: Foo.eth0i  FoozMessage is too long to send.z%Message is too long to send: foo bar.zDNS lookup failed.zDNS lookup failed: foo bar.z#An error occurred while connecting.z0An error occurred while connecting: someOsError.someOsErrorz(An error occurred while connecting: foo.stringz5An error occurred while connecting: someOsError: foo.zCouldn't bind.zCouldn't bind: someOsError.z Couldn't bind: someOsError: foo.zHostname couldn't be looked up.zNo route to host.z%Connection was refused by other side.zTCP connection timed out.z%File used for UNIX socket is no good.z&Service name given as port is unknown.zUser aborted connection.z'User timeout caused connection failure.zAn SSL error occurred.z=Connection to the other side was lost in a non-clean fashion.zFConnection to the other side was lost in a non-clean fashion: foo bar.zConnection was closed cleanly.z'Connection was closed cleanly: foo bar.zUh.z(Tried to cancel an already-called event.z1Tried to cancel an already-called event: foo bar.z+Tried to cancel an already-cancelled event.z0Tried to cancel an already-cancelled event: x 2.x2zOA process has ended without apparent errors: process finished with exit code 0.NzCA process has ended with a probable error condition: process ended.zUA process has ended with a probable error condition: process ended with exit code 42.exitCode*   zTA process has ended with a probable error condition: process ended by signal SIGBUS.signalSIGBUSzFThe Connector was not connecting when it was asked to stop connecting.zLThe Connector was not connecting when it was asked to stop connecting: x 13.13z?The Port was not listening when it was asked to stop listening.zEThe Port was not listening when it was asked to stop listening: a 12.a12z_list[tuple[str, type[Exception], Sequence[str | int | Exception | None], dict[str, str | int]]]listOfTestsreturnNonec           
         | j         D ]K}|d         }|d         }|d         }|d         }|                     t           ||i |          |           Ld S )Nr            )r   assertEqualstr)selfentryoutput	exceptionargskwargss         I/var/www/html/env/lib/python3.11/site-packages/twisted/test/test_error.pytestThemAllz StringificationTests.testThemAll   sv    % 	F 	FE1XFaI8D1XFSD!;F!;!;<<fEEEE	F 	F    c                    t                      }t          j        |          }|                     |j        |           dS )zP
        L{error.ConnectingCancelledError} has an C{address} attribute.
        N)objectr   ConnectingCancelledErrorassertIsaddress)r!   r.   es      r'   test_connectingCancelledErrorz2StringificationTests.test_connectingCancelledError   s9     ((*733ai)))))r)   r   r   )"__name__
__module____qualname____doc__r   	BindErrorCannotListenErrorsocketMessageLengthErrorDNSLookupErrorConnectErrorConnectBindErrorUnknownHostErrorNoRouteErrorConnectionRefusedErrorTCPTimedOutErrorBadFileErrorServiceNameUnknownError	UserErrorTimeoutErrorSSLErrorConnectionLostConnectionDoneConnectionFdescWentAwayAlreadyCalledAlreadyCancelledProcessDoneProcessTerminatedNotConnectingErrorNotListeningErrorr   __annotations__r(   r0    r)   r'   r   r      s0        @@^		5uBO^	 >OG		
^	 BOEN		
^	  1#T<6<../		
^	* 
()A2rJ+^	. 4$EN		
-^	8 
u3R<9^	: 
'(<uenbQ;^	< 
/0BBK=^	@ ?O		
?^	L 7u		
K^	X DE"		
W^	b 
512r:c^	d 
'(>QSTe^	h /"E"		
g^	r 
+E,BBKs^	t 
e0"b9u^	v 
1%2NPRTVWw^	x 
%e&<b"Ey^	z 
1%2Db"M{^	~ 5)		
}^	H 
$U_b"=I^	J 
3E4FBOK^	L 
"5>2r:M^	P L 		
O^	\ U EN		
[^	f 
*5+?RHg^	j 6 EN		
i^	v )		
u^	@ 
4U5H"bQA^	D @EN		
C^	N 
78NPRTVWO^	R ?"#J		
Q^	^ ^F		
]^	j R#		
i^	v d#		
u^	B c#x 		
A^	N U$		
M^	Z [$$K		
Y^	f N#		
e^	r T#$K		
q^	  e e e eNF F F F* * * * * *r)   r   c                  *    e Zd ZdZddZddZddZdS )	SubclassingTestsz=
    Some exceptions are subclasses of other exceptions.
    r   r   c                t    |                      t          t          j        t          j                             dS )zW
        L{error.ConnectionClosed} is a superclass of L{error.ConnectionLost}.
        N)
assertTrue
issubclassr   rF   ConnectionClosedr!   s    r'   -test_connectionLostSubclassOfConnectionClosedz>SubclassingTests.test_connectionLostSubclassOfConnectionClosed   ,     	
5#79OPPQQQQQr)   c                t    |                      t          t          j        t          j                             dS )zW
        L{error.ConnectionClosed} is a superclass of L{error.ConnectionDone}.
        N)rT   rU   r   rG   rV   rW   s    r'   -test_connectionDoneSubclassOfConnectionClosedz>SubclassingTests.test_connectionDoneSubclassOfConnectionClosed   rY   r)   c                j    |                      t          t          j        t                               dS )zP
        L{ValueError} is a superclass of L{error.InvalidAddressError}.
        N)rT   rU   r   InvalidAddressError
ValueErrorrW   s    r'   ,test_invalidAddressErrorSubclassOfValueErrorz=SubclassingTests.test_invalidAddressErrorSubclassOfValueError   s)     	
5#<jIIJJJJJr)   Nr1   )r2   r3   r4   r5   rX   r[   r_   rP   r)   r'   rR   rR      sh         R R R RR R R RK K K K K Kr)   rR   c                  :    e Zd ZdZddZddZddZddZddZdS )GetConnectErrorTestsz
    Given an exception instance thrown by C{socket.connect},
    L{error.getConnectError} returns the appropriate high-level Twisted
    exception instance.
    errnointexpectedClasstype[error.ConnectError]r   r   c                f    |df}t          j        |          }|                     |d||           dS )z
        When called with a tuple with the given errno,
        L{error.getConnectError} returns an exception which is an instance of
        the expected class.
        lalalaN)r   getConnectErrorassertCorrectException)r!   rb   rd   r/   results        r'   assertErrnoExceptionz)GetConnectErrorTests.assertErrnoException   s>     H&q))##E8V]KKKKKr)   
int | Nonemessager+   rj   error.ConnectErrorc                    |                      |j        |           |                      |j        |           |                      |j        |f           dS )z
        The given result of L{error.getConnectError} has the given attributes
        (C{osError} and C{args}), and is an instance of the given class.
        N)r   	__class__osErrorr%   )r!   rb   rm   rj   rd   s        r'   ri   z+GetConnectErrorTests.assertCorrectException   sU     	)=999///wj11111r)   c                   |                      t          j        t          j                   |                      t          j        t          j                   |                      t          j        t          j                   t          j
        dk    rV|                      t          j        t          j                   |                      t          j        t          j                   dS dS )zW
        L{error.getConnectError} converts based on errno for C{socket.error}.
        win32N)rk   rb   ENETUNREACHr   r>   ECONNREFUSEDr?   	ETIMEDOUTr@   sysplatformWSAECONNREFUSEDWSAENETUNREACHrW   s    r'   
test_errnozGetConnectErrorTests.test_errno  s     	!!%"3U5GHHH!!%"4e6RSSS!!%/53IJJJ<7""%%%u'C   %%e&:E<NOOOOO	 #"r)   c                    t          j        t          j        dd                    }|                     dd|t           j                   dS )z
        L{error.getConnectError} converts to a L{error.UnknownHostError} given
        a C{socket.gaierror} instance.
           helloN)r   rh   r8   gaierrorri   r=   )r!   rj   s     r'   test_gaierrorz"GetConnectErrorTests.test_gaierror  sC    
 &vr7'C'CDD##B9OPPPPPr)   c                    t                      }t          j        |          }|                     d||t          j                   dS )z
        L{error.getConnectError} converts to a L{error.ConnectError} given
        an argument that cannot be unpacked.
        N)	Exceptionr   rh   ri   r;   )r!   r/   rj   s      r'   test_nonTuplez"GetConnectErrorTests.test_nonTuple  s@    
 KK&q))##D!VU5GHHHHHr)   N)rb   rc   rd   re   r   r   )
rb   rl   rm   r+   rj   rn   rd   re   r   r   r1   )	r2   r3   r4   r5   rk   ri   r{   r   r   rP   r)   r'   ra   ra      s         
L 
L 
L 
L2 2 2 2"P P P PQ Q Q QI I I I I Ir)   ra   )
__future__r   rb   r8   rw   typingr   twisted.internetr   twisted.trialr   SynchronousTestCaser   rR   ra   rP   r)   r'   <module>r      s    # " " " " "   



       " " " " " " " " " " " "y* y* y* y* y*87 y* y* y*xK K K K Kx3 K K K0@I @I @I @I @I87 @I @I @I @I @Ir)   