
    Yf	                     \    d 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	dS )zL
Tests for async assertions provided by C{twisted.trial.unittest.TestCase}.
    N)defer)failure)unittestc                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	AsynchronousAssertionsTestszp
    Tests for L{TestCase}'s asynchronous extensions to L{SynchronousTestCase}.
    That is, assertFailure.
    c                 b    t          j        d           }|                     |t                    S )Nc                      ddz  S N   r    r       Y/var/www/html/env/lib/python3.11/site-packages/twisted/trial/test/test_asyncassertions.py<lambda>z@AsynchronousAssertionsTests.test_assertFailure.<locals>.<lambda>   
    A r   )r   maybeDeferredassertFailureZeroDivisionErrorselfds     r   test_assertFailurez.AsynchronousAssertionsTests.test_assertFailure   s+    ..!!!%6777r   c                      t          j        d           }                     |t                     |                     fd fd           |S )Nc                      ddz  S r
   r   r   r   r   r   zOAsynchronousAssertionsTests.test_assertFailure_wrongException.<locals>.<lambda>   r   r   c                 .                         d          S NzShould have failedfailxr   s    r   r   zOAsynchronousAssertionsTests.test_assertFailure_wrongException.<locals>.<lambda>       dii 455 r   c                 8    |                      j                  S NtrapfailureExceptionr   s    r   r   zOAsynchronousAssertionsTests.test_assertFailure_wrongException.<locals>.<lambda>       affT233 r   )r   r   r   OverflowErroraddCallbacksr   s   ` r   !test_assertFailure_wrongExceptionz=AsynchronousAssertionsTests.test_assertFailure_wrongException   s`    ..1m,,,	55553333	
 	
 	
 r   c                      t          j        d           }                     |t                     |                     fd fd           |S )Nc                 .                         d          S r   r   r   s    r   r   zLAsynchronousAssertionsTests.test_assertFailure_noException.<locals>.<lambda>'   r    r   c                 8    |                      j                  S r"   r#   r   s    r   r   zLAsynchronousAssertionsTests.test_assertFailure_noException.<locals>.<lambda>(   r&   r   )r   succeedr   r   r(   r   s   ` r   test_assertFailure_noExceptionz:AsynchronousAssertionsTests.test_assertFailure_noException#   s^    M$1/000	55553333	
 	
 	
 r   c                     	 ddz   n7# t           $ r* t          j                    }t          j        |          }Y nw xY w|                     |t                    }|                    | j        |           |S )z
        In the case of assertFailure failing, check that we get lots of
        information about the exception that was raised.
        r   r   )	r   r   Failurer   r   r   RuntimeError
addErrback
_checkInfo)r   fr   s      r   test_assertFailure_moreInfoz7AsynchronousAssertionsTests.test_assertFailure_moreInfo,   s}    
	EEE  	 	 	!!A
1AAA	 q,//	T_a(((s    1<<c                    |                     | j                  sJ |                                }|                     |                                |           |                     |                                |           d S r"   )checkr%   getErrorMessageassertIngetBriefTraceback)r   assertionFailurer4   outputs       r   r3   z&AsynchronousAssertionsTests._checkInfo:   sv    %%d&;<<<<<!1133a''))6222a))++V44444r   c                     G d dt                      G fddt          j                  } |d          }t          j                    }|                    |           |                     dt          |j                             dS )zJ
        A single wrong assertFailure should fail the whole test.
        c                       e Zd ZdS )MAsynchronousAssertionsTests.test_assertFailure_masked.<locals>.ExampleFailureN)__name__
__module____qualname__r   r   r   ExampleFailurer?   E   s        Dr   rC   c                       e Zd Z Zd ZdS )AAsynchronousAssertionsTests.test_assertFailure_masked.<locals>.TCc                     t          j        d           }|                     |t                     |                     |t                     |S )Nc                      ddz  S r
   r   r   r   r   r   zfAsynchronousAssertionsTests.test_assertFailure_masked.<locals>.TC.test_assertFailure.<locals>.<lambda>L   s
    A r   )r   r   r   r'   r   r   s     r   r   zTAsynchronousAssertionsTests.test_assertFailure_masked.<locals>.TC.test_assertFailureK   sF    '66""1m444""1&7888r   N)r@   rA   rB   r%   r   )rC   s   r   TCrE   H   s*        -    r   rH   r   r   N)		Exceptionr   TestCasepyunit
TestResultrunassertEquallenfailures)r   rH   testresultrC   s       @r   test_assertFailure_maskedz5AsynchronousAssertionsTests.test_assertFailure_masked@   s    
	 	 	 	 	Y 	 	 		 	 	 	 	 	 	" 	 	 	 r&''"$$C0011111r   N)
r@   rA   rB   __doc__r   r)   r.   r5   r3   rS   r   r   r   r   r      sx         
8 8 8      5 5 52 2 2 2 2r   r   )
rT   r   rK   twisted.internetr   twisted.pythonr   twisted.trialrJ   r   r   r   r   <module>rX      s    
     " " " " " " " " " " " " " " " " " "D2 D2 D2 D2 D2("3 D2 D2 D2 D2 D2r   