
    Vh	                     ^    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	y)zL
Tests for async assertions provided by C{twisted.trial.unittest.TestCase}.
    N)defer)failure)unittestc                   4    e Zd ZdZd Zd Zd Zd Zd Zd Z	y)	AsynchronousAssertionsTestszp
    Tests for L{TestCase}'s asynchronous extensions to L{SynchronousTestCase}.
    That is, assertFailure.
    c                 Z    t        j                  d       }| j                  |t              S )Nc                      ddz  S N   r    r       W/home/dcms/DCMS/lib/python3.12/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7r   c                      t        j                  d       } j                  |t               |j	                   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                 &    j                  d      S NzShould have failedfailxr   s    r   r   zOAsynchronousAssertionsTests.test_assertFailure_wrongException.<locals>.<lambda>       dii 45 r   c                 :    | j                  j                        S NtrapfailureExceptionr   s    r   r   zOAsynchronousAssertionsTests.test_assertFailure_wrongException.<locals>.<lambda>       affT223 r   )r   r   r   OverflowErroraddCallbacksr   s   ` r   !test_assertFailure_wrongExceptionz=AsynchronousAssertionsTests.test_assertFailure_wrongException   s<    .1m,	53	
 r   c                      t        j                  d       } j                  |t               |j	                   fd fd       |S )Nc                 &    j                  d      S r   r   r   s    r   r   zLAsynchronousAssertionsTests.test_assertFailure_noException.<locals>.<lambda>'   r    r   c                 :    | j                  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;    MM$1/0	53	
 r   c                     	 ddz   | j                  t              }|j                  | j                         |S # t         $ r, t        j                         }t        j                  |      }Y hw xY w)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,   sc    
	E q,/	T__a( ! 	!A

1A	s   ; 2A0/A0c                     |j                  | j                        sJ |j                         }| j                  |j                         |       | j                  |j	                         |       y r"   )checkr%   getErrorMessageassertIngetBriefTraceback)r   assertionFailurer4   outputs       r   r3   z&AsynchronousAssertionsTests._checkInfo:   sX    %%d&;&;<<<!113a'')62a))+V4r   c                      G d dt                G fddt        j                        } |d      }t        j                         }|j                  |       | j                  dt        |j                               y)zJ
        A single wrong assertFailure should fail the whole test.
        c                       e Zd Zy)MAsynchronousAssertionsTests.test_assertFailure_masked.<locals>.ExampleFailureN)__name__
__module____qualname__r   r   r   ExampleFailurer?   E   s    r   rC   c                       e Zd ZW  Zd Zy)AAsynchronousAssertionsTests.test_assertFailure_masked.<locals>.TCc                     t        j                  d       }| j                  |t               | j                  |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   s8    ''6""1m4""1&7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@   sa    
	Y 		"" 	 &'""$C01r   N)
r@   rA   rB   __doc__r   r)   r.   r5   r3   rS   r   r   r   r   r      s%    
852r   r   )
rT   r   rK   twisted.internetr   twisted.pythonr   twisted.trialrJ   r   r   r   r   <module>rX      s,   
  " " "D2("3"3 D2r   