Ë
    ojø	  ã                   ó^   — 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   ó    úI/usr/lib/python3/dist-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>   ó   ø€ �d—i‘iÐ 4Ó5€ r   c                 ó:   •— | j                  ‰j                  «      S ©N©ÚtrapÚfailureExceptionr   s    €r   r   zOAsynchronousAssertionsTests.test_assertFailure_wrongException.<locals>.<lambda>   ó   ø€ �a—f‘f˜T×2Ñ2Ó3€ r   )r   r   r   ÚOverflowErrorÚaddCallbacksr   s   ` r   Ú!test_assertFailure_wrongExceptionz=AsynchronousAssertionsTests.test_assertFailure_wrongException   s<   ø€ Ü×Ñ¡Ó.ˆØ×Ñ˜1œmÔ,Ø	�‰Û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;   ø€ Ü�M‰M˜$ÓˆØ×Ñ˜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�Ø×"Ñ" 1¤mÔ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   