
    i                     ~    S r SSKJr  SSKJr  SSKrSSKJr  SSK	J
r
  SSKJrJr   " S S	\5      r " S
 S\\5      rg)$Unit tests for kgb.agency.SpyAgency.    )unicode_literals)contextmanagerN)	SpyAgency)FunctionSig)	MathClassTestCasec                   0    \ rS rSrSrS rS rS rS rSr	g)	SpyAgencyTests   r   c                     [        5       nU R                  R                  UR                  5      nU R	                  U R                  R
                  [        U/5      5        g)zTesting SpyAgency.spy_onN)r   agencyspy_ondo_mathassertEqualspiesset)selfobjspys      X/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/kgb/tests/test_spy_agency.pytest_spy_onSpyAgencyTests.test_spy_on   sA    kkk  -**CJ7    c                    [        5       nU R                  R                  UR                  US9SS j5       nU R	                  UR                  5       S5        U R	                  U" U5      S5        U R                  UR                  R                  R                  U5        [        U5      nU R	                  UR                  S5        U R	                  UR                  [        R                  5        U R	                  UR                  S5        g)zTesting SpyAgency.spy_forownerNc                     g
Some docs.{    _selfabargskwargss        r   my_func,SpyAgencyTests.test_spy_for.<locals>.my_func        r   r!   r)   r    NN)r   r   spy_forr   r   assertIsr   funcr   	func_name	func_typeTYPE_FUNCTION__doc__r   r   r)   sigs       r   test_spy_forSpyAgencyTests.test_spy_for   s    k			S[[		4	 
5	 	,s+ckkoo**G4 '"	2(A(AB,7r   c                 L   [        5       nUR                  nU R                  R                  UR                  5      nU R	                  U R                  R
                  [        U/5      5        U R                  [        UR                  S5      5        U R                  R                  UR                  5        U R	                  U R                  R
                  [        5       5        U R                  [        UR                  S5      5        U R	                  UR                  U5        g)zTesting SpyAgency.unspyr   N)r   r   r   r   r   r   r   
assertTruehasattrunspyassertFalse)r   r   orig_do_mathr   s       r   
test_unspySpyAgencyTests.test_unspy*   s    k{{kk  -**CJ7U34#++&**CE2e45l3r   c                    [        5       nUR                  nU R                  R                  UR                  5      nU R                  R                  [         R                  5      nU R                  U R                  R                  [        X4/5      5        U R                  [        UR                  S5      5        U R                  [        [         R                  S5      5        U R                  R                  5         U R                  U R                  R                  [        5       5        U R                  UR                  U5        U R                  [         R                  U R                  5        U R                  [        UR                  S5      5        U R                  [        [         R                  S5      5        g)zTesting SpyAgency.unspy_allr   N)r   r   r   r   class_do_mathr   r   r   r9   r:   	unspy_allorig_class_do_mathr<   )r   r   r=   spy1spy2s        r   test_unspy_allSpyAgencyTests.test_unspy_all9   s%   k{{{{!!#++.{{!!)"9"9:**C,=>U34	 7 7?@**CE2l300$2I2IJe45!8!8%@Ar   r"   N)
__name__
__module____qualname____firstlineno__r3   r   r6   r>   rF   __static_attributes__r"   r   r   r   r      s    .88&4Br   r   c                   $   \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S  r"S! r#S" r$S# r%S$ r&S% r'S& r(S' r)S( r*S) r+S* r,S+ r-S, r.\/S- 5       r0S.r1g/)0TestCaseMixinTestsN   z-Unit tests for SpyAgency as a TestCase mixin.c                     [        5       nU R                  UR                  5        U R                  [	        UR                  S5      5        UR                  5       nU R                  US5        g)z&Testing SpyAgency mixed in with spy_onr      N)r   r   r   r9   r:   r   )r   r   results      r   r   TestCaseMixinTests.test_spy_onQ   sK    kCKK U34#r   c                    [        5       nU R                  UR                  5      SS j5       nU R                  UR                  5       S5        U R                  U" U5      S5        U R	                  UR                  R
                  R                  U5        [        U5      nU R                  UR                  S5        U R                  UR                  [        R                  5        U R                  UR                  S5        g)z'Testing SpyAgency mixed in with spy_forNc                     gr   r"   r#   s        r   r)   0TestCaseMixinTests.test_spy_for.<locals>.my_func_   r+   r   r!   r)   r    r,   )r   r-   r   r   r.   r   r/   r   r0   r1   r2   r3   r4   s       r   r6   TestCaseMixinTests.test_spy_for[   s    k	ckk	"	 
#	 	,s+ckkoo**G4 '"	2(A(AB,7r   c                 .   [        5       nUR                  nUR                  R                  R                  5       nU R	                  UR                  5        U R                  [        UR                  S5      5        U R                  X1R                  R                  5        U R                  5         U R                  UR                  U5        U R                  [        UR                  S5      5        U R                  X1R                  R                  5        g)z(Testing SpyAgency mixed in with tearDownr   N)r   r   __dict__copyr   r9   r:   assertNotEqualtearDownr   r<   )r   r   r=   	func_dicts       r   test_tear_down!TestCaseMixinTests.test_tear_downn   s    k{{KK((--/	CKK U34I{{';';<l3e45KK$8$89r   c                 p   U R                  [        R                  [        S9  U R                  [        R                  5        U R                  [        R                  R                  5        U R                  [        R                  5        [        R                  R                  [        R                  5        g)z'Testing SpyAgency.assertHasSpy with spyr   N)r   r   r   assertHasSpyr   assert_has_spykgbassertsr   s    r   test_assertHasSpy_with_spy-TestCaseMixinTests.test_assertHasSpy_with_spy~   s|    I%%# 	 	% 	)++,)++//0 	I--.""9#4#45r   c                     U R                  S5         U R                  [        R                  5        SSS5        g! , (       d  f       g= f)z*Testing SpyAgency.assertHasSpy without spyzdo_math has not been spied on.N)_check_assertionra   r   r   re   s    r   test_assertHasSpy_without_spy0TestCaseMixinTests.test_assertHasSpy_without_spy   s2    ""#CDi//0 EDDs	    ;
A	c                 v   [        5       nU R                  UR                  5        UR                  5         U R                  UR                  5        U R                  UR                  R                  5        U R                  UR                  5        [        R                  R                  UR                  5        g)z1Testing SpyAgency.assertSpyCalled with spy calledN)r   r   r   assertSpyCalledr   assert_spy_calledrc   rd   r   r   s     r    test_assertSpyCalled_with_called3TestCaseMixinTests.test_assertSpyCalled_with_called   sv    kCKK  	S[[)S[[__- 	s{{+%%ckk2r   c                 ~   [        5       nU R                  UR                  5        SnU R                  U5         U R	                  UR                  5        SSS5        U R                  U5         U R	                  UR                  R
                  5        SSS5        g! , (       d  f       NN= f! , (       d  f       g= f)z4Testing SpyAgency.assertSpyCalled without spy calleddo_math was not called.N)r   r   r   ri   rm   r   r   r   msgs      r   #test_assertSpyCalled_without_called6TestCaseMixinTests.test_assertSpyCalled_without_called   s    kCKK '""3'  - ( ""3'  1 (' (' ('s   B.&B.
B+.
B<c                 V   [        5       nU R                  UR                  5        U R                  UR                  5        U R                  UR                  R                  5        U R                  UR                  5        [        R                  R                  UR                  5        g)z7Testing SpyAgency.assertSpyNotCalled without spy calledN)r   r   r   assertSpyNotCalledr   assert_spy_not_calledrc   rd   ro   s     r   &test_assertSpyNotCalled_without_called9TestCaseMixinTests.test_assertSpyNotCalled_without_called   sm    kCKK  	,0 	""3;;/))#++6r   c                    [        5       nU R                  UR                  5        UR                  SSS9  UR                  SSS9  SnU R                  U5         U R	                  UR                  5        SSS5        U R                  U5         U R	                  UR                  R
                  5        SSS5        g! , (       d  f       NN= f! , (       d  f       g= f)z4Testing SpyAgency.assertSpyNotCalled with spy calledrQ      r&      	   zudo_math was called 2 times:

Call 0:
  args=()
  kwargs={'a': 3, 'b': 4}

Call 1:
  args=()
  kwargs={'a': 2, 'b': 9}N)r   r   r   ri   ry   r   rt   s      r   #test_assertSpyNotCalled_with_called6TestCaseMixinTests.test_assertSpyNotCalled_with_called   s    kCKK AA( 	 ""3'##CKK0 ( ""3'##CKKOO4 (' (' ('   B=&C=
C
Cc                    [        5       nU R                  UR                  5        UR                  5         UR                  5         U R                  UR                  S5        U R                  UR                  R                  S5        U R                  UR                  S5        [        R                  R                  UR                  S5        g)z=Testing SpyAgency.assertSpyCallCount with expected call countr   N)r   r   r   assertSpyCallCountr   assert_spy_call_countrc   rd   ro   s     r   +test_assertSpyCallCount_with_expected_count>TestCaseMixinTests.test_assertSpyCallCount_with_expected_count   s    kCKK  	Q/3 	""3;;2))#++q9r   c                    [        5       nU R                  UR                  5        UR                  5         U R                  S5         U R	                  UR                  S5        SSS5        UR                  5         U R                  S5         U R	                  UR                  R
                  S5        SSS5        g! , (       d  f       N_= f! , (       d  f       g= f)z@Testing SpyAgency.assertSpyCallCount without expected call countz!do_math was called 1 time, not 2.r   Nz"do_math was called 2 times, not 3.rQ   )r   r   r   ri   r   r   ro   s     r   .test_assertSpyCallCount_without_expected_countATestCaseMixinTests.test_assertSpyCallCount_without_expected_count   s    kCKK ""#FG##CKK3 H 	""#GH##CKKOOQ7 IH HG IHs   B='C=
C
Cc                     [        5       nU R                  UR                  5        SnU R                  U5         U R	                  UR                  5        SSS5        g! , (       d  f       g= f)z2Testing SpyAgency.assertSpyCalledOnce with 0 callsrs   Nr   r   r   ri   assertSpyCalledOncert   s      r   %test_assertSpyCalledOnce_with_0_calls8TestCaseMixinTests.test_assertSpyCalledOnce_with_0_calls   sL    kCKK  (""3'$$S[[1 (''   A
A,c                 v   [        5       nU R                  UR                  5        UR                  SSS9  U R                  UR                  5        U R                  UR                  R                  5        U R                  UR                  5        [        R                  R                  UR                  5        g)z1Testing SpyAgency.assertSpyCalledOnce with 1 call   r~   r   N)r   r   r   r   r   assert_spy_called_oncerc   rd   ro   s     r   %test_assertSpyCalledOnce_with_1_calls8TestCaseMixinTests.test_assertSpyCalledOnce_with_1_calls   s}    kCKK A 	  -  1 	##CKK0**3;;7r   c                    [        5       nU R                  UR                  5        UR                  SSS9  UR                  SSS9  SnU R                  U5         U R	                  UR                  5        SSS5        g! , (       d  f       g= f)z2Testing SpyAgency.assertSpyCalledOnce with 2 callsr   r~   r   r      do_math was not called exactly 1 time. It was called 2 times:

Call 0:
  args=()
  kwargs={'a': 1, 'b': 4}

Call 1:
  args=()
  kwargs={'a': 2, 'b': 8}Nr   rt   s      r   %test_assertSpyCalledOnce_with_2_calls8TestCaseMixinTests.test_assertSpyCalledOnce_with_2_calls  sq    kCKK AA( 	 ""3'$$S[[1 (''   A>>
Bc                     [        5       nU R                  UR                  5        SnU R                  U5         U R	                  UR                  SSS9  SSS5        g! , (       d  f       g= f)z6Testing SpyAgency.assertSpyCalledOnceWith with 0 callsrs   r   r   r%   r&   Nr   r   r   ri   assertSpyCalledOnceWithrt   s      r   )test_assertSpyCalledOnceWith_with_0_calls<TestCaseMixinTests.test_assertSpyCalledOnceWith_with_0_calls%  sS    kCKK  (""3'((Q(? (''r   c                 v   [        5       nU R                  UR                  5        UR                  SSS9  U R                  UR                  SSS9  U R                  UR                  R                  SSS9  U R                  UR                  SSS9  [        R                  R                  UR                  SSS9  g)z5Testing SpyAgency.assertSpyCalledOnceWith with 1 callr   r~   r   r   N)r   r   r   r   r   assert_spy_called_once_withrc   rd   ro   s     r   (test_assertSpyCalledOnceWith_with_1_call;TestCaseMixinTests.test_assertSpyCalledOnceWith_with_1_call0  s    kCKK A 	$$S[[A$;$$S[[__Q$? 	((Q(?//qA/Fr   c                     [        5       nU R                  UR                  5        UR                  SSS9  SnU R                  U5         U R	                  UR                  SSS9  SSS5        g! , (       d  f       g= f)zKTesting SpyAgency.assertSpyCalledOnceWith with 1 call with wrong
arguments
r   r~   r   zNo call to do_math was passed args=(1,), kwargs={'b': 8}.

The following calls were recorded:

Call 0:
  args=()
  kwargs={'a': 1, 'b': 4}r   Nr   rt   s      r   9test_assertSpyCalledOnceWith_with_1_calls_with_wrong_argsLTestCaseMixinTests.test_assertSpyCalledOnceWith_with_1_calls_with_wrong_args?  sj     kCKK A( 	 ""3'((a1(= (''s   	A..
A<c                    [        5       nU R                  UR                  5        UR                  SSS9  UR                  SSS9  SnU R                  U5         U R	                  UR                  SSS9  SSS5        g! , (       d  f       g= f)z6Testing SpyAgency.assertSpyCalledOnceWith with 2 callsr   r~   r   r   r   r   Nr   rt   s      r   )test_assertSpyCalledOnceWith_with_2_calls<TestCaseMixinTests.test_assertSpyCalledOnceWith_with_2_callsV  sx    kCKK AA( 	 ""3'((a1(= (''r   c                 J   [        5       nU R                  UR                  5        UR                  SSS9  UR                  SSS9  U R                  UR                  SSS9  U R                  UR                  R                  S   SSS9  U R                  UR                  R
                  SSS9  U R                  UR                  R
                  R                  S   SSS9  U R                  UR                  SSS9  [        R                  R                  UR                  SSS9  g)	z=Testing SpyAgency.assertSpyCalledWith with expected argumentsr   r~   r   r   r   r   r   N)	r   r   r   assertSpyCalledWithcallsr   assert_spy_called_withrc   rd   ro   s     r   0test_assertSpyCalledWith_with_expected_argumentsCTestCaseMixinTests.test_assertSpyCalledWith_with_expected_argumentsn  s    kCKK AA 	  Q 7  !2!21!5a @  A ;  !6!6q!9Q! D 	##CKK1#:**3;;!q*Ar   c                 |   [        5       nU R                  UR                  5        UR                  SSS9  UR                  SSS9  SnU R                  U5         U R	                  UR                  SSS9  SSS5        U R                  U5         U R	                  UR                  R
                  SSS9  SSS5        S	nU R                  U5         U R	                  UR                  R
                  R                  S
   SSS9  SSS5        g! , (       d  f       N= f! , (       d  f       Nn= f! , (       d  f       g= f)z@Testing SpyAgency.assertSpyCalledWith without expected argumentsr   r~   r   r   r   zNo call to do_math was passed args=(), kwargs={'x': 4, 'z': 1}.

The following calls were recorded:

Call 0:
  args=()
  kwargs={'a': 1, 'b': 4}

Call 1:
  args=()
  kwargs={'a': 2, 'b': 9})xzNz{This call to do_math was not passed args=(), kwargs={'x': 4, 'z': 1}.

It was called with:

args=()
kwargs={'a': 1, 'b': 4}r   )r   r   r   ri   r   r   r   rt   s      r   3test_assertSpyCalledWith_without_expected_argumentsFTestCaseMixinTests.test_assertSpyCalledWith_without_expected_arguments  s   kCKK AA
( 	 ""3'$$S[[A$; ( ""3'$$S[[__Q$? (& 	 ""3'$$S[[__%:%:1%=a$H ('! (' (' ('$   D&D3D-
D
D*-
D;c                 J   [        5       nU R                  UR                  5        UR                  SSS9  UR                  SSS9  U R                  UR                  SSS9  U R                  UR                  R                  S   SSS9  U R                  UR                  R
                  SSS9  U R                  UR                  R
                  R                  S   SSS9  U R                  UR                  SSS9  [        R                  R                  UR                  SSS9  g	)
zKTesting SpyAgency.assertSpyNotCalledWith with unexpected arguments
        r   r~   r   r   r   rQ   r   r   N)	r   r   r   assertSpyNotCalledWithr   r   assert_spy_not_called_withrc   rd   ro   s     r   5test_assertSpyNotCalledWith_with_unexpected_argumentsHTestCaseMixinTests.test_assertSpyNotCalledWith_with_unexpected_arguments  s     kCKK AA 	##CKK1#:##CKK$5$5a$8A#C##CKKOOqA#>##CKKOO$9$9!$<Q#G 	''qA'>..s{{a1.Er   c                 |   [        5       nU R                  UR                  5        UR                  SSS9  UR                  SSS9  SnU R                  U5         U R	                  UR                  SSS9  SSS5        U R                  U5         U R	                  UR                  R
                  SSS9  SSS5        S	nU R                  U5         U R	                  UR                  R
                  R                  S   SSS9  SSS5        g! , (       d  f       N= f! , (       d  f       Nn= f! , (       d  f       g= f)
zFTesting SpyAgency.assertSpyNotCalledWith without unexpected
arguments
r   r~   r   r   r   zA call to do_math was unexpectedly passed args=(), kwargs={'a': 1, 'b': 4}.

The following calls were recorded:

Call 0:
  args=()
  kwargs={'a': 1, 'b': 4}

Call 1:
  args=()
  kwargs={'a': 2, 'b': 9}r   NzNThis call to do_math was unexpectedly passed args=(), kwargs={'a': 2, 'b': 9}.)r   r   r   ri   r   r   r   rt   s      r   8test_assertSpyNotCalledWith_without_unexpected_argumentsKTestCaseMixinTests.test_assertSpyNotCalledWith_without_unexpected_arguments  s
    kCKK AA( 	 ""3'''qA'> ( ""3'''1'B (( 	
 ""3'''(=(=a(@A'K (' (' (' ('r   c                    [        5       nU R                  UR                  5        UR                  SSS9  UR                  SSS9  U R                  UR                  SSS9  U R                  UR                  R                  SSS9  U R                  UR                  SSS9  [        R                  R                  UR                  SSS9  g)zATesting SpyAgency.assertSpyLastCalledWith with expected argumentsr   r~   r   r   r   r   N)r   r   r   assertSpyLastCalledWithr   assert_spy_last_called_withrc   rd   ro   s     r   4test_assertSpyLastCalledWith_with_expected_argumentsGTestCaseMixinTests.test_assertSpyLastCalledWith_with_expected_arguments  s    kCKK AA 	$$S[[A$;$$S[[__Q$? 	((Q(?//qA/Fr   c                    [        5       nU R                  UR                  5        UR                  SSS9  UR                  SSS9  SnU R                  U5         U R	                  UR                  SSS9  SSS5        U R                  U5         U R	                  UR                  R
                  SSS9  SSS5        g! , (       d  f       NN= f! , (       d  f       g= f)	zETesting SpyAgency.assertSpyLastCalledWith without expected
arguments
r   r~   r   r   r   zThe last call to do_math was not passed args=(), kwargs={'a': 1, 'b': 4}.

It was last called with:

args=()
kwargs={'a': 2, 'b': 9}r   N)r   r   r   ri   r   r   rt   s      r   7test_assertSpyLastCalledWith_without_expected_argumentsJTestCaseMixinTests.test_assertSpyLastCalledWith_without_expected_arguments  s     kCKK AA& 	 ""3'((Q(? ( ""3'((A(C (' (' ('r   c                 V   [        5       nU R                  UR                  5        UR                  SSS9  UR                  SSS9  U R                  UR                  S5        U R                  UR                  R                  S   S5        U R                  UR                  R
                  S5        U R                  UR                  R
                  R                  S   S5        U R                  UR                  S5        [        R                  R                  UR                  S5        g	)
z>Testing SpyAgency.assertSpyReturned with expected return valuer   r~   r   r   r      r      N)	r   r   r   assertSpyReturnedr   r   assert_spy_returnedrc   rd   ro   s     r   +test_assertSpyReturned_with_expected_return>TestCaseMixinTests.test_assertSpyReturned_with_expected_return  s    kCKK AA 	s{{A.s{{003Q7s{{3s{{44Q7< 	  a0''Q7r   c                 n   [        5       nU R                  UR                  5        UR                  SSS9  UR                  SSS9  SnU R                  U5         U R	                  UR                  S5        SSS5        U R                  U5         U R	                  UR                  R
                  S5        SSS5        S	nU R                  U5         U R	                  UR                  R                  S
   S5        SSS5        g! , (       d  f       N= f! , (       d  f       Ne= f! , (       d  f       g= f)zATesting SpyAgency.assertSpyReturned without expected return valuer   r~   r   r   r   zeNo call to do_math returned 100.

The following values have been returned:

Call 0:
  5

Call 1:
  11d   Nz9This call to do_math did not return 100.

It returned:

5r   )r   r   r   ri   r   r   r   rt   s      r   .test_assertSpyReturned_without_expected_returnATestCaseMixinTests.test_assertSpyReturned_without_expected_return  s    kCKK AA 	 ""3'""3;;4 ( ""3'""3;;??C8 ( 	 ""3'""3;;#4#4Q#7= (' (' (' ('s$   D'D*D&
D
D#&
D4c                    [        5       nU R                  UR                  5        UR                  SSS9  UR                  SSS9  U R                  UR                  S5        U R                  UR                  R                  S5        U R                  UR                  S5        [        R                  R                  UR                  S5        g)zKTesting SpyAgency.assertSpyLastReturned with expected return value
        r   r~   r   r   r   r   N)r   r   r   assertSpyLastReturnedr   assert_spy_last_returnedrc   rd   ro   s     r   /test_assertSpyLastReturned_with_expected_returnBTestCaseMixinTests.test_assertSpyLastReturned_with_expected_returnD  s     kCKK AA 	""3;;3""3;;??B7 	%%ckk26,,S[["=r   c                    [        5       nU R                  UR                  5        UR                  SSS9  UR                  SSS9  SnU R                  U5         U R	                  UR                  S5        SSS5        U R                  U5         U R	                  UR                  R
                  S5        SSS5        g! , (       d  f       NO= f! , (       d  f       g= f)	zFTesting SpyAgency.assertSpyLastReturned without expected return
value
r   r~   r   r   r   zAThe last call to do_math did not return 5.

It last returned:

11r   N)r   r   r   ri   r   r   rt   s      r   2test_assertSpyLastReturned_without_expected_returnETestCaseMixinTests.test_assertSpyLastReturned_without_expected_returnU  s     kCKK AA 	 ""3'&&s{{A6 ( ""3'&&s{{: (' (' ('s   B?'C?
C
Cc                    S n[        5       nU R                  UR                  US9   UR                  S5         UR                  S5        U R                  UR                  [        5        U R                  UR                  R                  S   [        5        U R                  UR                  R                  [        5        U R                  UR                  R                  R                  S   [        5        U R                  UR                  [        5        [        R                  R                  UR                  [        5        g! [         a     GNf = f! [         a     GNf = f)z@Testing SpyAgency.assertSpyRaised with expected exception raisedc                 4    US:X  a  [         eUS:X  a  [        eg Nr   r   KeyError
ValueErrorr$   r%   r'   r(   s       r   _do_mathQTestCaseMixinTests.test_assertSpyRaised_with_expected_exception.<locals>._do_matho       Ava   r   	call_faker   r   r   N)r   r   r   r   r   assertSpyRaisedr   r   assert_spy_raisedrc   rd   r   r   r   s      r   ,test_assertSpyRaised_with_expected_exception?TestCaseMixinTests.test_assertSpyRaised_with_expected_exceptionm  s	   	! kCKK84	KKN	KKN
 	S[[(3S[[..q18<S[[__j9S[[__2215zB 	s{{H5%%ckk8<!  		
  		s"   E	 E 	
EE
E('E(c                    [        5       nU R                  UR                  5        UR                  S5        UR                  S5        U R                  UR                  S5        U R                  UR                  R                  S   S5        U R                  UR                  R
                  S5        U R                  UR                  R
                  R                  S   S5        g)zOTesting SpyAgency.assertSpyRaised with expected completions without
exceptions
r   r   Nr   )r   r   r   r   r   r   ro   s     r   /test_assertSpyRaised_with_expected_no_exceptionBTestCaseMixinTests.test_assertSpyRaised_with_expected_no_exception  s     kCKK AA 	S[[$/S[[..q148S[[__d3S[[__2215t<r   c                    S n[        5       nU R                  UR                  US9   UR                  S5         UR                  S5        SnU R                  U5         U R                  UR                  [        5        SSS5        U R                  U5         U R                  UR                  R                  [        5        SSS5        SnU R                  U5         U R                  UR                  R                  S   [        5        SSS5        g! [         a     Nf = f! [         a     Nf = f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       g= f)	zLTesting SpyAgency.assertSpyRaised without expected exception raised
        c                 4    US:X  a  [         eUS:X  a  [        eg r   r   r   s       r   r   TTestCaseMixinTests.test_assertSpyRaised_without_expected_exception.<locals>._do_math  r   r   r   r   r   zNo call to do_math raised AttributeError.

The following exceptions have been raised:

Call 0:
  KeyError

Call 1:
  ValueErrorNzFThis call to do_math did not raise AttributeError. It raised KeyError.r   )
r   r   r   r   r   ri   r   AttributeErrorr   r   r   r   r   ru   s       r   /test_assertSpyRaised_without_expected_exceptionBTestCaseMixinTests.test_assertSpyRaised_without_expected_exception  s'   	! kCKK84	KKN	KKN
 	 ""3'  n= ( ""3'  .A ( 	
 ""3'  !2!21!5~F ('?  		
  		 (' (' ('sF   D D& !D6+E.E
D#"D#&
D32D36
E
E
E&c                    [        5       nU R                  UR                  5        UR                  S5        UR                  S5        SnU R                  U5         U R	                  UR                  [
        5        SSS5        U R                  U5         U R	                  UR                  R                  [
        5        SSS5        SnU R                  U5         U R	                  UR                  R                  R                  S   [
        5        SSS5        g! , (       d  f       N= f! , (       d  f       Ns= f! , (       d  f       g= f)z?Testing SpyAgency.assertSpyRaised without any exceptions raisedr   r   'No call to do_math raised an exception.Nz0This call to do_math did not raise an exception.r   )r   r   r   ri   r   r   r   r   rt   s      r   #test_assertSpyRaised_without_raised6TestCaseMixinTests.test_assertSpyRaised_without_raised  s    kCKK  	AA7""3'  n= ( ""3'  .A ( A""3'  !6!6q!9>J (' (' ('
 ('s$   !D+D-8D>
D*-
D;>
Ec                 
   S n[        5       nU R                  UR                  US9   UR                  S5         UR                  S5        U R                  UR                  [        5        U R                  UR                  R                  [        5        U R                  UR                  [        5        [        R                  R                  UR                  [        5        g! [         a     Nf = f! [         a     Nf = f)zETesting SpyAgency.assertSpyLastRaised with expected exception
raised
c                 4    US:X  a  [         eUS:X  a  [        eg r   r   r   s       r   r   UTestCaseMixinTests.test_assertSpyLastRaised_with_expected_exception.<locals>._do_math  r   r   r   r   r   N)
r   r   r   r   r   assertSpyLastRaisedr   assert_spy_last_raisedrc   rd   r   s      r   0test_assertSpyLastRaised_with_expected_exceptionCTestCaseMixinTests.test_assertSpyLastRaised_with_expected_exception  s    	! kCKK84	KKN	KKN
 	  j9  *= 	##CKK<**3;;
C  		
  		s"   C% C5 %
C21C25
DDc                    [        5       nU R                  UR                  5        UR                  S5        UR                  S5        U R                  UR                  S5        U R                  UR                  R                  S5        g)zOTesting SpyAgency.assertSpyLastRaised with expected completion
without raising
r   r   N)r   r   r   r   r   ro   s     r   3test_assertSpyLastRaised_with_expected_no_exceptionFTestCaseMixinTests.test_assertSpyLastRaised_with_expected_no_exception  s_     kCKK AA 	  d3  $7r   c                    S n[        5       nU R                  UR                  US9   UR                  S5         UR                  S5        SnU R                  U5         U R                  UR                  [        5        SSS5        U R                  U5         U R                  UR                  R                  [        5        SSS5        g! [         a     Nf = f! [         a     Nf = f! , (       d  f       Ns= f! , (       d  f       g= f)zHTesting SpyAgency.assertSpyLastRaised without expected exception
raised
c                 4    US:X  a  [         eUS:X  a  [        eg r   r   r   s       r   r   XTestCaseMixinTests.test_assertSpyLastRaised_without_expected_exception.<locals>._do_math  r   r   r   r   r   zKThe last call to do_math did not raise KeyError. It last raised ValueError.N)r   r   r   r   r   ri   r   r   r   s       r   3test_assertSpyLastRaised_without_expected_exceptionFTestCaseMixinTests.test_assertSpyLastRaised_without_expected_exception  s    	! kCKK84	KKN	KKN
! 	
 ""3'$$S[[(; ( ""3'$$S[[__h? ('!  		
  		 (' ('s:   C C !C-+C>
CC
C*)C*-
C;>
Dc                    [        5       nU R                  UR                  5        UR                  S5        UR                  S5        SnU R                  U5         U R	                  UR                  [
        5        SSS5        U R                  U5         U R	                  UR                  R                  [
        5        SSS5        g! , (       d  f       NS= f! , (       d  f       g= f)z>Testing SpyAgency.assertSpyLastRaised without exception raisedr   r   4The last call to do_math did not raise an exception.N)r   r   r   ri   r   r   r   rt   s      r   'test_assertSpyLastRaised_without_raised:TestCaseMixinTests.test_assertSpyLastRaised_without_raised2  s    kCKK AAD""3'$$S[[(; ( ""3'$$S[[__h? (' (' ('s   !C	+C	
C
C(c                    S n[        5       nU R                  UR                  US9   UR                  S5         UR                  S5        U R                  UR                  [        S5        U R                  UR                  R                  S   [        S5        U R                  UR                  R                  [        S5        U R                  UR                  R                  R                  S   [        S5        U R                  UR                  [        S5        [        R                  R                  UR                  [        S5        g! [         a     GN"f = f! [         a     GN!f = f)	zMTesting SpyAgency.assertSpyRaised with expected exception and
message raised
c                 H    US:X  a  [        S5      eUS:X  a  [        S5      eg Nr   Bad key!r   
Bad value!r   r   r   s       r   r   NTestCaseMixinTests.test_assertSpyRaisedMessage_with_expected.<locals>._do_mathF  +    Av$Z00a .. r   r   r   r   r  r   r  N)r   r   r   r   r   assertSpyRaisedMessager   r   assert_spy_raised_messagerc   rd   r   s      r   )test_assertSpyRaisedMessage_with_expected<TestCaseMixinTests.test_assertSpyRaisedMessage_with_expectedB  s   	/ kCKK84	KKN	KKN
 	##CKKL##CKK$5$5a$8.$.	0##CKKOOZN##CKKOO$9$9!$<j$0	2 	&&s{{NJO--ckk>.8	:%  		
  		s"   E E  
EE 
E.-E.c                 :   S n[        5       nU R                  UR                  US9   UR                  S5         UR                  S5        SS< S[        S5      < S	[        S
5      < 3nU R                  U5         U R                  UR                  [        S5        SSS5        U R                  U5         U R                  UR                  R                  [        S5        SSS5        SS< S[        S5      < 3nU R                  U5         U R                  UR                  R                  S   [        S5        SSS5        g! [         a     GNf = f! [         a     GNf = f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       g= f)zWTesting SpyAgency.assertSpyRaisedMessage without expected exception
and message raised
c                 H    US:X  a  [        S5      eUS:X  a  [        S5      eg r  r  r   s       r   r   QTestCaseMixinTests.test_assertSpyRaisedMessage_without_expected.<locals>._do_mathj  r  r   r   r   r   z6No call to do_math raised AttributeError with message z
Bad key...z\.

The following exceptions have been raised:

Call 0:
  exception=AttributeError
  message=r  z+

Call 1:
  exception=ValueError
  message=r  Nz?This call to do_math did not raise AttributeError with message z0.

It raised:

exception=AttributeError
message=r   )
r   r   r   r   r   strri   r  r   r   r   s       r   ,test_assertSpyRaisedMessage_without_expected?TestCaseMixinTests.test_assertSpyRaisedMessage_without_expectedf  sW   	/ kCKK84	KKN	KKN$ S_c,.?A 	 ""3'''^(46 ( ""3'''(46 ( S_. 	 ""3'''(9(9!(<n(46 ('Y  		
  		( (' (' ('sF   E E ="E*8,E;/F
EE
E'&E'*
E8;
F	
Fc                    [        5       nU R                  UR                  5        UR                  S5        UR                  S5        SnU R                  U5         U R	                  UR                  [
        S5        SSS5        U R                  U5         U R	                  UR                  R                  [
        S5        SSS5        g! , (       d  f       NT= f! , (       d  f       g= f)zJTesting SpyAgency.assertSpyRaisedMessage without exception raised
        r   r   r   ...N)r   r   r   ri   r  r   r   rt   s      r   *test_assertSpyRaisedMessage_without_raised=TestCaseMixinTests.test_assertSpyRaisedMessage_without_raised  s     kCKK AA7""3'''XuE ( ""3'''5I (' (' ('   "C,C
C
C*c                    S n[        5       nU R                  UR                  US9   UR                  S5         UR                  S5        U R                  UR                  [        S5        U R                  UR                  R                  [        S5        U R                  UR                  [        S5        [        R                  R                  UR                  [        S5        g! [         a     Nf = f! [         a     Nf = f)zQTesting SpyAgency.assertSpyLastRaised with expected exception and
message raised
c                 H    US:X  a  [        S5      eUS:X  a  [        S5      eg r  r  r   s       r   r   RTestCaseMixinTests.test_assertSpyLastRaisedMessage_with_expected.<locals>._do_math  r  r   r   r   r   r  N)
r   r   r   r   r   assertSpyLastRaisedMessager   assert_spy_last_raised_messagerc   rd   r   s      r   -test_assertSpyLastRaisedMessage_with_expected@TestCaseMixinTests.test_assertSpyLastRaisedMessage_with_expected  s    	/ kCKK84	KKN	KKN
 	''ZN''(4	6 	++CKK,8	:223;;
3?	A!  		
  		s"   C) C9 )
C65C69
DDc                 D   S n[        5       nU R                  UR                  US9   UR                  S5         UR                  S5        SS< S[        S5      < 3nU R                  U5         U R                  UR                  [        S5        S	S	S	5        U R                  U5         U R                  UR                  R                  [        S5        S	S	S	5        g	! [         a     Nf = f! [         a     Nf = f! , (       d  f       Nt= f! , (       d  f       g	= f)
z[Testing SpyAgency.assertSpyLastRaisedMessage without expected
exception and message raised
c                 H    US:X  a  [        S5      eUS:X  a  [        S5      eg r  r  r   s       r   r   UTestCaseMixinTests.test_assertSpyLastRaisedMessage_without_expected.<locals>._do_math  r  r   r   r   r   zCThe last call to do_math did not raise AttributeError with message r  z1.

It last raised:

exception=ValueError
message=r  N)	r   r   r   r   r   r  ri   r)  r   r   s       r   0test_assertSpyLastRaisedMessage_without_expectedCTestCaseMixinTests.test_assertSpyLastRaisedMessage_without_expected  s    	/ kCKK84	KKN	KKN 3|,. 	 ""3'++CKK,68 ( ""3'++CKKOO^,68 ('3  		
  		  (' ('s:   C  C0 0"D +,D 
C-,C-0
C=<C= 
D
Dc                    [        5       nU R                  UR                  5        UR                  S5        UR                  S5        SnU R                  U5         U R	                  UR                  [
        S5        SSS5        U R                  U5         U R	                  UR                  R                  [
        S5        SSS5        g! , (       d  f       NT= f! , (       d  f       g= f)zFTesting SpyAgency.assertSpyLastRaisedMessage without exception
raised
r   r   r  r"  N)r   r   r   ri   r)  r   r   rt   s      r   .test_assertSpyLastRaisedMessage_without_raisedATestCaseMixinTests.test_assertSpyLastRaisedMessage_without_raised  s     kCKK AAD""3'++CKK5I ( ""3'++CKKOOXuM (' (' ('r%  c              #      #    U R                  [        5       nSv   SSS5        U R                  [        WR                  5      U5        g! , (       d  f       N4= f7f)zCheck that the expected assertion and message is raised.

Args:
    msg (unicode):
        The assertion message.

Context:
    The context used to run an assertion.
N)assertRaisesAssertionErrorr   r  	exception)r   ru   ctxs      r   ri   #TestCaseMixinTests._check_assertion  sB      ~.# / 	S]]+S1 /.s   AA.A
AAr"   N)2rH   rI   rJ   rK   r3   r   r6   r^   rf   rj   rp   rv   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r	  r  r  r  r#  r+  r0  r3  r   ri   rL   r"   r   r   rN   rN   N   s   7$8&: 61
32754: 8 	2820	@G>.>0B$'IRF&%LNG D48$#>J>";0=>= /GbK,D>8 @D@ ":H=6~J" AD*8XN$ 2 2r   rN   )r3   
__future__r   
contextlibr   kgb.assertsrc   
kgb.agencyr   kgb.signaturer   kgb.tests.baser   r	   r   rN   r"   r   r   <module>rA     s9    * ' %    % .>BX >BBV2H V2r   