
    i                    r   S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S SK
Jr  S SKJrJr  S SKJr  S SKJr  S SKJrJr  \" \S5      r\" \S	5      rS
 rSS jrS rSS jrS rS rS rS r \SS j5       r! " S S\"5      r# " S S\#5      r$ " S S\"5      r% " S S\"5      r& " S S\5      r'g)    )unicode_literalsN)contextmanager)ExistingSpyErrorIncompatibleFunctionError)	text_type)FunctionSig)	MathClassTestCase
getargspecgetfullargspecc                 F   ^  [         R                  " T 5      U 4S j5       nU$ )zRequire getargspec for a unit test.

If not available, the test will be skipped.

Args:
    func (callable):
        The unit test function to decorate.
c                     > [         (       a&  [        R                  " SS9   T" U 0 UD6sS S S 5        $ [        R                  " S[
        R                  S S -  5      e! , (       d  f       g = f)NT)recordz6inspect.getargspec is not available on Python %s.%s.%s   )has_getargspecwarningscatch_warningsunittestSkipTestsysversion_info)argskwargsfuncs     Z/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/kgb/tests/test_function_spy.py_wrap!require_getargspec.<locals>._wrap    sa    >((5T,V, 65 ##H""2A&'( ( 65s   A
A+)	functoolswraps)r   r   s   ` r   require_getargspecr       s'     __T( ( L    c                 
    X-
  $ N abr   r   s       r   do_mathr(   -   	    5Lr!   c                 
    X-
  $ r#   r$   r&   r'   s     r   do_math_posr,   1   r)   r!   c                 
    X-
  $ r#   r$   r%   s       r   do_math_mixedr.   5   r)   r!   c                 8    [        U [        5      (       d   eX-
  $ r#   )
isinstancer	   )selfr&   r'   r   r   s        r   fake_do_mathr2   9   s    dI&&&&5Lr!   c                 8    [        U [        5      (       d   eX-
  $ r#   )
issubclassr	   )clsr&   r'   r   r   s        r   fake_class_do_mathr6   ?   s    c9%%%%5Lr!   c                      g)NTada!r$   r$   r!   r   something_awesomer9   E   s    r!   c                      g)N\o/r$   r$   r!   r   fake_something_awesomer<   I   s    r!   c              #      #    X-   v   g 7fr#   r$   r+   s     r   
do_contextr>   M   s     
%K   
c                   @    \ rS rSrS rS r\S 5       r\S 5       rSr	g)AdderObjectR   c                 |    [        U [        5      (       d   eS Vs/ s H  oR                  U5      PM     sn$ s  snf N      r   )r0   rA   add_oner1   is     r   r   AdderObject.funcS   s3    $,,,,)23AQ333s   9c                 :    [        U [        5      (       d   eUS-   $ NrF   )r0   rA   rI   s     r   rH   AdderObject.add_oneX   s    $,,,,1ur!   c                 d    U [         L d   eS Vs/ s H  oR                  U5      PM     sn$ s  snf rD   )rA   class_add_oner5   rJ   s     r   
class_funcAdderObject.class_func]   s1    k!!!.78i!!!$i888s   -c                 :    [        U [        5      (       d   eUS-   $ rM   )r4   rA   rQ   s     r   rP   AdderObject.class_add_onec   s    #{++++1ur!   r$   N)
__name__
__module____qualname____firstlineno__r   rH   classmethodrR   rP   __static_attributes__r$   r!   r   rA   rA   R   s4    4

 9 9
  r!   rA   c                       \ rS rSrSrg)AdderSubclassj   r$   NrV   rW   rX   rY   r[   r$   r!   r   r]   r]   j   s    r!   r]   c                   .    \ rS rSrSrS rS rSS jrSrg)	slippery_funcn   r   c                     g r#   r$   r1   s    r   __init__slippery_func.__init__q   s    r!   c                     Xl         U $ r#   method)r1   ri   s     r   __call__slippery_func.__call__t   s    r!   Nc                    ^ ^^ [         R                  " T R                  5      UUU 4S j5       mT R                  Tl        [        T 5      =R                  S-  sl        T$ )Nc                  <   > TR                  TTR                  5      $ r#   )ri   counter)r   r   _wrapperobjr1   s     r   ro   'slippery_func.__get__.<locals>._wrappery   s    ;;sH$4$455r!   rF   )r   r   ri   countrn   type)r1   rp   objtypero   s   `` @r   __get__slippery_func.__get__x   sJ    		%	6 
&	6  ::T
Ar!   rh   r#   )	rV   rW   rX   rY   rr   re   rj   ru   r[   r$   r!   r   ra   ra   n   s    Er!   ra   c                   .    \ rS rSr\" 5       S 5       rSrg)SlipperyFuncObject   c                     U$ r#   r$   )r1   values     r   my_funcSlipperyFuncObject.my_func   s    r!   r$   N)rV   rW   rX   rY   ra   r|   r[   r$   r!   r   rx   rx      s    _ r!   rx   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- r/S. r0S/ r1S0 r2S1 r3S2 r4S3 r5S4 r6S5 r7S6 r8S7 r9S8 r:S9 r;S: r<S; r=S< r>S= r?S> r@S? rAS@ rBSA rCSB rDSC rESD rFSE rGSF rHSG rISH rJSI rKSJ rLSK rMSL rNSM rOSN rPSO rQSP rRSQ rSSR rTSS rUST rVSU rWSV rXSW rYSX rZSY r[SZ r\S[ r]S\ r^S] r_S^ r`S_ raS` rbSa rcSb rdSc reSd rfSe rgSf rhSg riSh rjSi rkSj rlSk rmSl rn\oSm 5       rp\oSn 5       rq\oSo 5       rr\oSp 5       rsStSr jrtSsrugq)uFunctionSpyTests   z%Test cases for kgb.spies.FunctionSpy.c                     U R                   R                  [        [        SS9nU R	                  UR
                  [        5        g)z<Testing FunctionSpy construction with call option precedenceT)	call_fakecall_originalN)agencyspy_onr9   r<   assertEqualr   r1   spys     r   &test_construction_with_call_precedence7FunctionSpyTests.test_construction_with_call_precedence   s;    kk  !2+A/3 ! 5 	#9:r!   c                 r   U R                   R                  [        [        S9nU R	                  [        [        S5      5        U R                  [        R                  U5        U R                  [        UR                  [        R                  5      [        [        [        R                  5      5        U R                  UR                  [        5        U R                  UR                  S5        U R                  UR                  UR                  5        U R!                  [        ["        R$                  5        g)z/Testing FunctionSpy construction with call_faker   r   r9   N)r   r   r9   r<   
assertTruehasattrr   r   getattrr   r   FUNC_NAME_ATTR	orig_func	func_name	func_typeTYPE_FUNCTIONassertIsInstancetypesFunctionTyper   s     r    test_construction_with_call_fake1FunctionSpyTests.test_construction_with_call_fake   s    kk  !2+A ! C 	 159:*..4CHHk889*K,F,FG	I 	(9:(;<(9(9:/1C1CDr!   c                    [        5       nUR                  nU R                  R                  UR                  [        S9nU R                  [        UR                  S5      5        U R                  UR                  R                  U5        U R                  UR                  U5        U R                  [        [         R                  S5      5        U R                  UR                  [        5        U R                  UR                  S5        U R                  UR                  UR                  5        U R!                  UR                  ["        R$                  5        g)z@Testing FunctionSpy construction with call_fake and bound methodr   r   r(   N)r	   r(   r   r   r2   r   r   assertIsr   assertIsNotassertFalser   r   r   r   TYPE_BOUND_METHODr   r   
MethodType)r1   rp   orig_methodr   s       r   1test_construction_with_call_fake_and_bound_methodBFunctionSpyTests.test_construction_with_call_fake_and_bound_method   s    kkkkk   EU34ckkoos+k2!2!2E:;<0	2(=(=>ckk5+;+;<r!   c                    [         R                  nU R                  R                  [         R                  [        S9nU R                  [        [         R                  S5      5        U R                  [         R                  R                  U5        U R                  UR                  [        5        U R                  UR                  S5        U R                  UR                  UR                  5        U R                  UR                  [         5        [        U[         R"                  5      (       a!  U R                  [         R                  U5        O][        U[         R$                  5      (       a!  U R'                  [         R                  U5        OU R)                  S[+        U5      -  5        [        5       nU R                  [        UR                  S5      5        U R                  UR                  R                  [         R                  R                  5        U R-                  UR                  [         R$                  5        g)zKTesting FunctionSpy construction with call_fake and unbound method
        r   r   r(    Method has an unexpected type %rN)r	   r(   r   r   r2   r   r   r   r   r   r   r   r   TYPE_UNBOUND_METHODownerr0   r   r   r   r   failrs   r   )r1   r   r   rp   s       r   3test_construction_with_call_fake_and_unbound_methodDFunctionSpyTests.test_construction_with_call_fake_and_unbound_method   sx     ''kk  !2!2l K	 1 159:i''++S1<0	2(?(?@I.k5#5#566MM)++[9U%5%566Y..<II84;LLMkU34ckkooy'8'8'<'<=ckk5+;+;<r!   c                 x   S n[         R                  nU R                  R                  [         R                  US9nU R	                  [        [         R                  S5      5        U R                  [         R                  R                  U5        U R                  [         R                  U5        U R                  UR                  U5        U R                  UR                  U R                  5        U R                  UR                  S5        U R                  [         R                  [        R                  5        g)z?Testing FunctionSpy construction with call_fake and classmethodc                     g)N*   r$   )r5   r   r   s      r   r6   ]FunctionSpyTests.test_construction_with_call_fake_and_classmethod.<locals>.fake_class_do_math   s    r!   r   r   class_do_mathN)r	   r   r   r   r   r   r   r   r   r   r   orig_class_do_mathr   r   r   r   )r1   r6   r   r   s       r   0test_construction_with_call_fake_and_classmethodAFunctionSpyTests.test_construction_with_call_fake_and_classmethod   s    	  --kk  !8!8+= ! ? 		 7 7?@i--1137i--{;#56(?(?@8i55u7G7GHr!   c                    [        5       nU R                  R                  UR                  SS9nU R	                  [        UR                  S5      5        U R                  UR                  R                  U5        U R                  UR                  5        U R                  UR                  S5        U R                  UR                  [        R                  5        g)z9Testing FunctionSpy construction with call_original=FalseFr   r   r(   N)r	   r   r   r(   r   r   r   r   assertIsNoner   r   r   r   r   r   )r1   rp   r   s      r   *test_construction_with_call_original_false;FunctionSpyTests.test_construction_with_call_original_false   s    kkk  E BU34ckkoos+#((#	2ckk5+;+;<r!   c                    U R                   R                  [        SS9nU R                  [	        [        S5      5        U R                  [        R                  U5        U R                  [        UR                  [        R                  5      [        [        [        R                  5      5        U R                  UR                  [        5        U R                  UR                  S5        U R                  [        [        R                  5        g)z8Testing FunctionSpy construction with call_original=TrueTr   r   r9   N)r   r   r9   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s     r   )test_construction_with_call_original_true:FunctionSpyTests.test_construction_with_call_original_true   s    kk  !2$ G 159:*..4CHHk889%{'A'AB	D 	(9:(;</1C1CDr!   c                 p   [        5       nUR                  nU R                  R                  UR                  SS9nU R	                  [        UR                  S5      5        U R                  UR                  R                  U5        U R                  [        [         R                  S5      5        U R                  UR                  U5        U R                  UR                  S5        U R                  UR                  UR                  5        U R                  UR                  [        R                   5        g)zJTesting FunctionSpy construction with call_original=True and bound
method
Tr   r   r(   N)r	   r(   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r1   rp   orig_do_mathr   s       r   :test_construction_with_call_original_true_and_bound_methodKFunctionSpyTests.test_construction_with_call_original_true_and_bound_method   s     k{{kk  D AU34ckkoos+!2!2E:;5	2(=(=>ckk5+;+;<r!   c                 &   U R                   R                  [        R                  SS9nU R	                  [        [        R                  S5      5        U R                  [        R                  R                  U5        U R                  UR                  U R                  5        U R                  UR                  S5        U R                  UR                  UR                  5        U R                  [        R                  [        R                   5        g)zLTesting FunctionSpy construction with call_original and classmethod
        Tr   r   r   N)r   r   r	   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s     r   4test_construction_with_call_original_and_classmethodEFunctionSpyTests.test_construction_with_call_original_and_classmethod
  s     kk  !8!8 M	 7 7?@i--1137(?(?@8(=(=>i55u7G7GHr!   c                     U R                  [        5       nU R                  R                  [        [
        S9  SSS5        U R                  [        WR                  5      S5        g! , (       d  f       N4= f)z@Testing FunctionSpy constructions with function and owner passedr   Nz@This function has no owner, but an owner was passed to spy_on().)	assertRaises
ValueErrorr   r   r(   rA   r   r   	exceptionr1   cms     r   )test_construction_with_function_and_owner:FunctionSpyTests.test_construction_with_function_and_owner  sW    z*bKKwk: + 	2<<0/	0 +*s   #A''
A5c                    [        5       nUR                  nUR                  nU R                  U[        R                  5        U R                  U[        R                  5        U R                  X#5        U R                  R                  UR                  USS9nU R                  [        UR                  S5      5        U R                  UR                  R                  U5        U R                  UR                  S5        U R                  UR                  UR                  5        U R                  UR                  [        R                   5        S["        l        UR                  nUR                  nU R                  X#5        U R                  U" 5       S5        U R                  U" 5       S5        U R                  U" 5       S5        U R                  ['        UR                  R(                  5      S5        g	)
zTesting FunctionSpy construction with new slippery function
generated dynamically from accessing a spied-on bound method from
instance
T)r   r   r   r|   r   rF   rG   r   N)rx   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ra   rr   lencalls)r1   rp   func1func2r   s        r   $test_init_with_slippery_bound_method5FunctionSpyTests.test_init_with_slippery_bound_method   ss   
 !" eU%7%78eU%7%78&kk  '*/3 ! 5 	U34ckkoos+	2(=(=>ckk5+;+;<e#
 	!$!$!$S[[../3r!   c                    U R                  [        5       nU R                  R                  [        R
                  [        S9  SSS5        U R                  [        WR                  5      S5        g! , (       d  f       N4= f)zTesting FunctionSpy construction with new slippery function
generated dynamically from accessing a spied-on unbound method from
instance
r   NzUnable to spy on unbound slippery methods (those that return a new function on each attribute access). Please spy on an instance instead.)	r   r   r   r   rx   r|   r   r   r   r   s     r   &test_init_with_slippery_unbound_method7FunctionSpyTests.test_init_with_slippery_unbound_methodF  sf    
 z*bKK199%7  9 + 	bll# 	!	 +*s   -A11
A?c                     " S S[         5      n " S SU5      nU" 5       nUR                  nU R                  R                  UR                  5      nU R	                  [        UR                  S5      5        U R                  [        UR                  S5      5        U R                  UR                  R                  U5        U R                  UR                  S5        U R                  UR                  UR                  5        U R                  UR                  U5        [        U[        R                   5      (       a  U R                  UR                  U5        OY[        U[        R"                  5      (       a  U R%                  UR                  U5        OU R'                  S[)        U5      -  5        U" 5       nU R	                  [        UR                  S5      5        U R                  UR                  R                  UR                  R                  5        U R+                  UR                  [        R"                  5        U" 5       nU R                  [        UR                  S5      5        g)	zGTesting FunctionSpy construction with classmethod from parent of
class
c                   $    \ rS rSr\S 5       rSrg)OFunctionSpyTests.test_construction_with_classmethod_on_parent.<locals>.MyParentiY  c                     g r#   r$   rd   s    r   fooSFunctionSpyTests.test_construction_with_classmethod_on_parent.<locals>.MyParent.fooZ      r!   r$   NrV   rW   rX   rY   rZ   r   r[   r$   r!   r   MyParentr   Y       r!   r   c                       \ rS rSrSrg)OFunctionSpyTests.test_construction_with_classmethod_on_parent.<locals>.MyObjecti^  r$   Nr_   r$   r!   r   MyObjectr   ^      r!   r   r   r   r   N)objectr   r   r   r   r   r   r   r   r   r   r   r   r   r0   r   r   r   r   r   rs   r   )r1   r   r   rp   r   r   obj2obj3s           r   ,test_construction_with_classmethod_on_parent=FunctionSpyTests.test_construction_with_classmethod_on_parentU  s   	v 	
	x 	 jggkk  .e45u56hll&&,.(=(=>H-k5#5#566MM(,,4U%5%566X\\;7II84;LLMz%01dhhllHLL$4$45dhh(8(89z512r!   c                 
   [        5       nUR                  nU R                  R                  [         R                  [         S9nU R	                  [        [         R                  S5      5        U R                  [        [        R                  S5      5        U R                  [         R                  R                  U5        U R                  UR                  S5        U R                  UR                  UR                  5        U R                  UR                  [         5        [        U[         R"                  5      (       a!  U R                  [         R                  U5        O][        U[         R$                  5      (       a!  U R'                  [         R                  U5        OU R)                  S[+        U5      -  5        [        5       nU R	                  [        UR                  S5      5        U R                  UR                  R                  [         R                  R                  5        U R-                  UR                  [         R$                  5        [        5       nU R                  [        UR                  S5      5        g)zJTesting FunctionSpy construction with unbound method from parent of
class
r   r   r   r   N)r]   r   r   r   r   r   r   rA   r   r   r   r   r   r   r   r0   r   r   r   r   r   rs   r   )r1   rp   r   r   r   r   s         r   /test_construction_with_unbound_method_on_parent@FunctionSpyTests.test_construction_with_unbound_method_on_parent~  s    ohhkk  !3!3= I 2 2E:;!1!159:m((,,c2/(?(?@M2k5#5#566MM-,,k:U%5%566]//=II84;LLM		512diimm]%7%7%;%;<dii)9)9:}E23r!   c                     " S S[         5      nU" 5       nUR                  nU R                  U5        U R                  R	                  UR                  5      nU R                  UR                  U5        U R                  UR                  U5        U R                  UR                  S5        U R                  UR                  UR                  5        U R                  UR                  [        R                  5        g)z>Testing FunctionSpy construction with a falsy function.im_selfc                       \ rS rSrS rSrg)GFunctionSpyTests.test_construction_with_falsy_im_self.<locals>.MyObjecti  c                     g r#   r$   rd   s    r   r   KFunctionSpyTests.test_construction_with_falsy_im_self.<locals>.MyObject.foo      r!   r$   NrV   rW   rX   rY   r   r[   r$   r!   r   r   r         r!   r   r   N)dictr   r   r   r   r   r   assertNotEqualr   r   r   r   r   r   )r1   r   	my_objectorig_foor   s        r   $test_construction_with_falsy_im_self5FunctionSpyTests.test_construction_with_falsy_im_self  s    	t 	 J	== 	#kk  /1HLL#..(=(=>immU-=-=>r!   c                   ^  U 4S jnU" 5         T R                  [        5       nT R                  R                  [        5        SSS5        T R                  S[        WR                  5      5        g! , (       d  f       N4= f)z@Testing FunctionSpy constructions with function already spied onc                  D   > T R                   R                  [        5        g r#   )r   r   r(   rd   s   r   	setup_spyGFunctionSpyTests.test_construction_with_existing_spy.<locals>.setup_spy  s    KKw'r!   Nz, in setup_spy)r   r   r   r   r(   assertInr   r   )r1   r   r   s   `  r   #test_construction_with_existing_spy4FunctionSpyTests.test_construction_with_existing_spy  sZ    	( 	/0BKKw' 1 	&	",,(?@ 10s    A22
B c                     " S S[         5      nU" 5       nUR                  nU R                  R                  UR                  5      nU R	                  UR
                  U5        U R                  UR                  U5        U R	                  UR                  S5        U R	                  UR                  UR                  5        U R                  UR                  [        R                  5        U R                  [        UR                  S5      5        U R                  [        UR                  S5      5        U" 5       nU R                  [        UR                  S5      5        g)zaTesting FunctionSpy constructions with a bound method on a class
containing a custom __setattr__
c                        \ rS rSrS rS rSrg)YFunctionSpyTests.test_construction_with_bound_method_and_custom_setattr.<locals>.MyObjecti  c                      er#   r$   r1   keyr{   s      r   __setattr__eFunctionSpyTests.test_construction_with_bound_method_and_custom_setattr.<locals>.MyObject.__setattr__      ur!   c                     g r#   r$   rd   s    r   r   ]FunctionSpyTests.test_construction_with_bound_method_and_custom_setattr.<locals>.MyObject.foo  r   r!   r$   NrV   rW   rX   rY   r  r   r[   r$   r!   r   r   r        r!   r   r   r   called_withN)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r1   r   rp   r   r   r   s         r   6test_construction_with_bound_method_and_custom_setattrGFunctionSpyTests.test_construction_with_bound_method_and_custom_setattr  s    	v 	 j77kk  )1HLL#..(=(=>cggu'7'78/078z512r!   c                 >    " S S[         5      n " S S[         5      nU" 5       nU R                  [        5       nU R                  R	                  UR
                  US9  SSS5        U R                  [        WR                  5      S5        g! , (       d  f       N4= f)zcTesting FunctionSpy constructions with a bound method and an
explicit owner not matching the class
c                       \ rS rSrS rSrg)TFunctionSpyTests.test_construction_with_bound_method_and_bad_owner.<locals>.MyObjecti  c                     g r#   r$   rd   s    r   r   XFunctionSpyTests.test_construction_with_bound_method_and_bad_owner.<locals>.MyObject.foo  r   r!   r$   Nr   r$   r!   r   r   r    r   r!   r   c                       \ rS rSrS rSrg)UFunctionSpyTests.test_construction_with_bound_method_and_bad_owner.<locals>.BadObjecti  c                     g r#   r$   rd   s    r   r   YFunctionSpyTests.test_construction_with_bound_method_and_bad_owner.<locals>.BadObject.foo  r   r!   r$   Nr   r$   r!   r   	BadObjectr    r   r!   r  r   NzEThe owner passed does not match the actual owner of the bound method.)	r   r   r   r   r   r   r   r   r   )r1   r   r  rp   r   s        r   1test_construction_with_bound_method_and_bad_ownerBFunctionSpyTests.test_construction_with_bound_method_and_bad_owner  s|    	v 		 	 jz*bKKswwi8 + 	2<<00	1 +*s   %B
Bc                 (    " S S[         5      nU" 5       nU R                  [        5       nU R                  R	                  UR
                  [        S9  SSS5        U R                  [        WR                  5      S5        g! , (       d  f       N4= f)z^Testing FunctionSpy constructions with an owner passed that does
not provide the spied method
c                       \ rS rSrS rSrg)NFunctionSpyTests.test_construction_with_owner_without_method.<locals>.MyObjecti  c                     g r#   r$   rd   s    r   r   RFunctionSpyTests.test_construction_with_owner_without_method.<locals>.MyObject.foo  r   r!   r$   Nr   r$   r!   r   r   r    r   r!   r   r   Nz3The owner passed does not contain the spied method.)
r   r   r   r   r   r   rA   r   r   r   )r1   r   rp   r   s       r   +test_construction_with_owner_without_method<FunctionSpyTests.test_construction_with_owner_without_method  so    	v 	 jz*bKKswwk: + 	2<<0N	P +*s   )B
Bc                     U R                  [        5       nU R                  R                  S5        SSS5        U R	                  [        WR                  5      S5        g! , (       d  f       N4= f)z3Testing FunctionSpy constructions with non-functionr   NzK42 cannot be spied on. It does not appear to be a valid function or method.)r   r   r   r   r   r   r   r   s     r   #test_construction_with_non_function4FunctionSpyTests.test_construction_with_non_function  sR    z*bKKr" + 	2<<05	6 +*s   A  
A.c                     U R                  [        5       nU R                  R                  [        SS9  SSS5        U R                  [        WR                  5      S5        g! , (       d  f       N4= f)z@Testing FunctionSpy constructions with call_fake as non-functionTr   NzWTrue cannot be used for call_fake. It does not appear to be a valid function or method.)r   r   r   r   r(   r   r   r   r   s     r   -test_construction_with_call_fake_non_function>FunctionSpyTests.test_construction_with_call_fake_non_function  sY    z*bKKw$7 + 	2<<0D	E +*s   A##
A1c                    S nS nSS jnSS jnU R                  [        5         U R                  R                  US S9  SSS5        U R                  [        5         U R                  R                  US S9  SSS5        U R                  [        5         U R                  R                  US	 S9  SSS5        U R                  [        5         U R                  R                  US
 S9  SSS5        U R                  [        5         U R                  R                  USS jS9  SSS5        U R                  [        5         U R                  R                  USS jS9  SSS5        U R                  [        5         U R                  R                  USS jS9  SSS5        U R                  R                  US S9  UR	                  5         U R                  R                  US S9  UR	                  5         U R                  R                  USS jS9  UR	                  5         U R                  R                  USS jS9  UR	                  5         U R                  R                  USS jS9  UR	                  5         U R                  R                  US S9  UR	                  5         U R                  R                  US S9  UR	                  5         g! , (       d  f       GN= f! , (       d  f       GNx= f! , (       d  f       GNQ= f! , (       d  f       GN*= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f)zNTesting FunctionSpy constructions with call_fake with signature
compatibility
c                     g r#   r$   r+   s     r   source1PFunctionSpyTests.test_construction_with_call_fake_compatibility.<locals>.source1      r!   c                     g r#   r$   )r&   r'   r   s      r   source2PFunctionSpyTests.test_construction_with_call_fake_compatibility.<locals>.source2  r,  r!   c                     g r#   r$   cds     r   source3PFunctionSpyTests.test_construction_with_call_fake_compatibility.<locals>.source3  r,  r!   c                     g r#   r$   r2  r3  r   s      r   source4PFunctionSpyTests.test_construction_with_call_fake_compatibility.<locals>.source4  r,  r!   c                     g r#   r$   r&   r'   r2  s      r   <lambda>QFunctionSpyTests.test_construction_with_call_fake_compatibility.<locals>.<lambda>#  s    $r!   r   Nc                     g r#   r$   r&   s    r   r<  r=  (  s    Dr!   c                      g r#   r$   r   s    r   r<  r=  -      4r!   c                     g r#   r$   r+   s     r   r<  r=  2  s    tr!   c                     g r#   r$   r2  s    r   r<  r=  7  s    dr!   c                     g r#   r$   )r2  r3  es      r   r<  r=  <  s    r!   c                     g r#   r$   r1  s     r   r<  r=  A  rB  r!   c                     g r#   r$   r+   s     r   r<  r=  C  s    4r!   c                      g r#   r$   )r   s    r   r<  r=  F  s    Dr!   c                     g r#   r$   r7  s      r   r<  r=  I  s    r!   c                     g r#   r$   )r2  r   s     r   r<  r=  L  s    Dr!   c                     g r#   r$   r7  s      r   r<  r=  O  s    $r!   c                     g r#   r$   )r2  rG  r   s      r   r<  r=  R  s    Tr!   c                      g r#   r$   rA  s    r   r<  r=  U  s    tr!   rF   rG   )rF   rE   r#   )r   r   r   r   unspy)r1   r*  r.  r4  r8  s        r   .test_construction_with_call_fake_compatibility?FunctionSpyTests.test_construction_with_call_fake_compatibility  s   				 89KK.  0 :
 89KK(  * :
 89KK/  1 :
 89KK+  - :
 89KK*  , :
 89KK4  6 :
 89KK/  1 :
 	7.?@7.@A7.MN7.HI7.NO7.IJ7.CDm :9
 :9
 :9
 :9
 :9
 :9
 :9sS   KK,K>L
L"L4 M
K),
K;>
L
L"
L14
M
Mc                      " S S5      nU" 5       nU R                   R                  UR                  S S9  U R                  UR                  5       S5        g)z(Testing FunctionSpy with old-style classc                       \ rS rSrS rSrg)HFunctionSpyTests.test_construction_with_old_style_class.<locals>.MyClassiZ  c                     g)Nd   r$   rd   s    r   	test_funcRFunctionSpyTests.test_construction_with_old_style_class.<locals>.MyClass.test_func[  s    r!   r$   N)rV   rW   rX   rY   rY  r[   r$   r!   r   MyClassrV  Z  s    r!   r[  c                     g)N   r$   )rp   s    r   r<  IFunctionSpyTests.test_construction_with_old_style_class.<locals>.<lambda>`  s    r!   r   r]  N)r   r   rY  r   )r1   r[  rp   s      r   &test_construction_with_old_style_class7FunctionSpyTests.test_construction_with_old_style_classX  sF    	 	 i3==OD#.r!   c                    U R                   R                  [        [        S9  [        5       nU R	                  US5        U R	                  [        [        R                  R                  5      S5        U R	                  [        [        R                  R                  S   R                  5      S5        U R	                  [        [        R                  R                  S   R                  5      S5        g)z(Testing FunctionSpy calls with call_faker   r;   rF   r   N)
r   r   r9   r<   r   r   r   r   r   r   r1   results     r   test_call_with_fake$FunctionSpyTests.test_call_with_fakec  s    ,%; 	 	="$(.228891=.2288;@@A1E.2288;BBCQGr!   c                 \   [        5       nU R                  R                  UR                  [        S9  UR                  5       nU R                  US5        U R                  [        UR                  R                  5      S5        U R                  UR                  R                  SSS95        g)z9Testing FunctionSpy calls with call_fake and bound methodr   rF   rG   r+   N)
r	   r   r   r(   r2   r   r   r   r   last_called_withr1   rp   rc  s      r   $test_call_with_fake_and_bound_method5FunctionSpyTests.test_call_with_fake_and_bound_methodn  s    k3;;,?$S[[../344 5  	r!   c                 d   U R                   R                  [        R                  [        S9  [        5       nUR                  5       nU R                  US5        U R                  [        UR                  R                  5      S5        U R                  UR                  R                  SSS95        g)z;Testing FunctionSpy calls with call_fake and unbound methodr   rg  rF   rG   r+   N)
r   r   r	   r(   r2   r   r   r   r   rh  ri  s      r   &test_call_with_fake_and_unbound_method7FunctionSpyTests.test_call_with_fake_and_unbound_method{  s    9,,Ek$S[[../344 5  	r!   c                 j   U R                   R                  [        R                  [        S9  [        R                  " 5       nU R                  US5        U R                  [        [        R                  R                  5      S5        U R                  [        R                  R                  SSS95        g)z8Testing FunctionSpy calls with call_fake and classmethodr   rF   rG      r+   N)
r   r   r	   r   r6   r   r   r   r   rh  rb  s     r   #test_call_with_fake_and_classmethod4FunctionSpyTests.test_call_with_fake_and_classmethod  s    922%7 	 	9((*$Y44::;Q?	//@@ A  	r!   c                    [         SS j5       nU R                  R                  [        US9  [        SS9 nUnSSS5        U R	                  WS5        U R	                  [        [        R                  5      S5        U R	                  [        R                  S   R                  S	5        U R	                  [        R                  S   R                  S
S05        g! , (       d  f       N= f)z<Testing FunctionSpy calls with call_fake and context managerrF   c              3      #    X-  v   g 7fr#   r$   r+   s     r   fake_do_contextPFunctionSpyTests.test_call_with_fake_and_contextmanager.<locals>.fake_do_context       %Kr?   r   rq  r?  N
   r   r$   r&   rP  )	r   r   r   r>   r   r   r   r   r   )r1   rv  ctxrc  s       r   &test_call_with_fake_and_contextmanager7FunctionSpyTests.test_call_with_fake_and_contextmanager  s    		 
	 	:%4 	 	6 !_F  	$Z--.2))!,1126))!,33c1X> _s   C
C'c                   ^ [        S5      m[        U4S j5       nU R                  R                  [        US9  U R                  [         S5         [	        SS9    SSS5        SSS5        U R                  [        [        R                  5      S5        U R                  [        R                  S   R                  S	5        U R                  [        R                  S   R                  S
S05        U R                  [        R                  S   R                  T5        g! , (       d  f       N= f! , (       d  f       N= f)z[Testing FunctionSpy calls with call_fake and context manager and
function raises exception
oh noc                     > Ter#   r$   )r   r   rG  s     r   rv  fFunctionSpyTests.test_call_with_fake_and_contextmanager_func_raises_exception.<locals>.fake_do_context  s    Gr!   r   rq  r?  NrF   r   r$   r&   )	Exceptionr   r   r   r>   assertRaisesRegexr   r   r   r   r   r   )r1   rv  rG  s     @r   <test_call_with_fake_and_contextmanager_func_raises_exceptionMFunctionSpyTests.test_call_with_fake_and_contextmanager_func_raises_exception  s     g		 
	 	:%4 	 	6 ##Iw7a ! 8 	Z--.2))!,1126))!,33c1X>))!,66: ! 87s$   
D0DD0
D-	)D00
D>c                 r   [        S5      n[        SS j5       nU R                  R                  [        US9  U R                  [         S5         [	        SS9   Ue! , (       d  f       O= f SSS5        O! , (       d  f       O= fU R                  [        [        R                  5      S5        U R                  [        R                  S   R                  S	5        U R                  [        R                  S   R                  S
S05        U R                  [        R                  S   R                  5        g)z_Testing FunctionSpy calls with call_fake and context manager and
context body raises exception
r~  rF   c              3      #    X-  v   g 7fr#   r$   r+   s     r   rv  fFunctionSpyTests.test_call_with_fake_and_contextmanager_body_raises_exception.<locals>.fake_do_context  rx  r?   r   rq  r?  Nr   r$   r&   rP  )r  r   r   r   r>   r  r   r   r   r   r   r   r   )r1   rG  rv  s      r   <test_call_with_fake_and_contextmanager_body_raises_exceptionMFunctionSpyTests.test_call_with_fake_and_contextmanager_body_raises_exception  s     g		 
	 	:%4 	 	6 ##Iw7a ! 877 	Z--.2))!,1126))!,33c1X>***1-778s   
A6A
A)	%A66
Bc                   ^ [        S5      mSU4S jjnUR                  n[        US5      nU(       a#  [        [	        UR                  5       5      5      nOS nU R                  R                  U5        U(       a=  [        [	        UR                  R                  5       5      5      nU R                  XE5         U" 5         U R                  [        UR                  5      S5        U R!                  UR                  S   R"                  T5        g ! [         a0  n[        R                  " [        R                  " 5       6    S nANS nAff = f)Nr~  c                    >     SnUnSn[        S5       H  n / SQnUnUnUnM     Te! [          a    e f = f! [          a    e f = f! [          a    e f = f)NrF   rG   )rF   rG   r      rq  ry  )r  range)arg1arg2r&   r'   r2  rJ   r3  rG  s          r   r   <FunctionSpyTests.test_call_with_exception.<locals>.orig_func  s    " !A !A !A 2Y'AAAA  G%  ) "!"
   ! s    : + 
A	7: A	Aco_positionsrF   r   )NN)r   __code__r   r   listr  r   r   assertGreaterr  	tracebackprint_exceptionr   exc_infor   r   r   r   )r1   r   orig_func_codesupports_co_positionsorig_positions_countspy_positions_countexrG  s          @r   test_call_with_exception)FunctionSpyTests.test_call_with_exception  s    w	D #++ ' G #&tN,G,G,I'J#K #'  	9% "%d9+=+=+J+J+L&M"N 3I	7K 	Y__-q1iooa(22A6  	7 %%s||~6		7s   9D 
E	&EE	c                    [        5       nU R                  R                  UR                  [        S9  UR                  SS5      nU R                  US5        U R                  [        UR                  R                  5      S5        U R                  UR                  R                  S   R                  S5        U R                  UR                  R                  S   R                  0 5        g)	z6Testing FunctionSpy calls with call_fake and argumentsr   ry     rF   r   ry  r  N)
r	   r   r   r,   r2   r   r   r   r   r   ri  s      r   test_call_with_fake_and_args-FunctionSpyTests.test_call_with_fake_and_args  s    k3??lCR(%S__223Q7..q166A..q188"=r!   c                    [        5       nU R                  R                  UR                  [        S9  UR                  SS5      nU R                  US5        U R                  [        UR                  R                  5      S5        U R                  UR                  R                  S   R                  S5        U R                  UR                  R                  S   R                  SSS.5        g	)
z`Testing FunctionSpy calls with call_fake and positional arguments
in place of keyword arguments
r   ry  r  r  rF   r   r$   r+   N
r	   r   r   r(   r2   r   r   r   r   r   ri  s      r   'test_call_with_fake_and_args_for_kwargs8FunctionSpyTests.test_call_with_fake_and_args_for_kwargs  s     k3;;,?R$%S[[../3**1-22B7**1-447
 	r!   c                    [        5       nU R                  R                  UR                  [        S9  UR                  SSS9nU R                  US5        U R                  [        UR                  R                  5      S5        U R                  [        UR                  R                  S   R                  5      S5        U R                  UR                  R                  S   R                  SSS.5        g)	z>Testing FunctionSpy calls with call_fake and keyword argumentsr   ry  r  r+   r  rF   r   Nr  ri  s      r   test_call_with_fake_and_kwargs/FunctionSpyTests.test_call_with_fake_and_kwargs0  s    k3;;,?rR(%S[[../3S[[..q1667;**1-447
 	r!   c                 R   [        5       nU R                  R                  UR                  SS9  UR                  5       nU R	                  U5        U R                  [        UR                  R                  5      S5        U R                  UR                  R                  SSS95        g)z2Testing FunctionSpy calls with call_original=FalseFr   rF   rG   r+   N)
r	   r   r   r(   r   r   r   r   r   rh  ri  s      r   test_call_with_original_false.FunctionSpyTests.test_call_with_original_false?  s|    k3;;e<&!S[[../344qA4>?r!   c                    [        5       nU R                  R                  UR                  SS9  UR                  SS5      nU R	                  U5        U R                  [        UR                  R                  5      S5        U R                  UR                  R                  S   R                  S5        U R                  UR                  R                  S   R                  0 5        g)	zLTesting FunctionSpy calls with call_original=False and positional
arguments
Fr   ry  r  rF   r   r  N)
r	   r   r   r,   r   r   r   r   r   r   ri  s      r   *test_call_with_all_original_false_and_args;FunctionSpyTests.test_call_with_all_original_false_and_argsJ  s     k3??%@R(&!S__223Q7..q166A..q188"=r!   c                    [        5       nU R                  R                  UR                  SS9  UR                  SS5      nU R	                  US5        U R	                  [        UR                  R                  5      S5        U R	                  UR                  R                  S   R                  S5        U R	                  UR                  R                  S   R                  SSS	.5        g)
zjTesting FunctionSpy calls with call_original=False and positional
arguments in place of keyword arguments
Fr   ry  r  NrF   r   r$   r+   	r	   r   r   r(   r   r   r   r   r   ri  s      r   5test_call_with_all_original_false_and_args_for_kwargsFFunctionSpyTests.test_call_with_all_original_false_and_args_for_kwargsX  s     k3;;e<R$&S[[../3**1-22B7**1-447
 	r!   c                    [        5       nU R                  R                  UR                  SS9  UR                  SSS9nU R	                  US5        U R	                  [        UR                  R                  5      S5        U R	                  [        UR                  R                  S   R                  5      S5        U R	                  UR                  R                  S   R                  SSS.5        g)	zITesting FunctionSpy calls with call_original=False and keyword
arguments
Fr   ry  r  r+   NrF   r   r  ri  s      r   (test_call_with_original_false_and_kwargs9FunctionSpyTests.test_call_with_original_false_and_kwargsi  s     k3;;e<rR(&S[[../3S[[..q1667;**1-447
 	r!   c                    U R                   R                  [        SS9  [        5       nU R                  US5        U R	                  [        [        S5      5        U R                  [        [        R                  R                  5      S5        U R                  [        [        R                  R                  S   R                  5      S5        U R                  [        [        R                  R                  S   R                  5      S5        g)z>Testing FunctionSpy calls with call_original=True and functionTr   r8   r   rF   r   N)r   r   r9   r   r   r   r   r   r   r   r   rb  s     r   )test_call_with_original_true_and_function:FunctionSpyTests.test_call_with_original_true_and_functionz  s    ,DA"$) 159:.228891=.2288;@@A1E.2288;BBCQGr!   c                    U R                   R                  [        SS9  [        SS5      nU R                  US5        U R                  [	        [        R
                  R                  5      S5        U R                  [        R
                  R                  S   R                  S5        U R                  [	        [        R
                  R                  S   R                  5      S5        g	)
z]Testing FunctionSpy calls with call_original=True and function
with all positional arguments
Tr   ry  r  r  rF   r   r  N)	r   r   r,   r   r   r   r   r   r   rb  s     r   .test_call_with_original_true_and_function_args?FunctionSpyTests.test_call_with_original_true_and_function_args  s     	;d;R$%[__223Q7..q166A[__2215<<=qAr!   c                    U R                   R                  [        SS9  [        SS5      nU R                  US5        U R                  [	        [        R
                  R                  5      S5        U R                  [        R
                  R                  S   R                  S5        U R                  [        R
                  R                  S   R                  SSS	.5        g
)z{Testing FunctionSpy calls with call_original=True and function
with all positional arguments in place of keyword arguments
Tr   ry  r  r  rF   r   r$   r+   N	r   r   r(   r   r   r   r   r   r   rb  s     r   9test_call_with_original_true_and_function_args_for_kwargsJFunctionSpyTests.test_call_with_original_true_and_function_args_for_kwargs  s     	7$7R%W[[../3**1-22B7**1-447
 	r!   c                    U R                   R                  [        SS9  [        SSS9nU R                  US5        U R                  [	        [        R
                  R                  5      S5        U R                  [	        [        R
                  R                  S   R                  5      S5        U R                  [        R
                  R                  S   R                  SSS.5        g	)
zZTesting FunctionSpy calls with call_original=True and function
with all keyword arguments
Tr   ry  r  )r'   r&   rF   r   r+   Nr  rb  s     r   0test_call_with_original_true_and_function_kwargsAFunctionSpyTests.test_call_with_original_true_and_function_kwargs  s     	7$72$$W[[../3W[[..q1667;**1-447
 	r!   c                 8   U R                   R                  [        SS9  [        SSSS9nU R                  US5        U R                  [	        [        R
                  R                  5      S5        U R                  [        R
                  R                  S   R                  S	5        U R                  [        R
                  R                  S   R                  SSSS
.5        U R                   R                  [        SS9  [        SSS9nU R                  US5        U R                  [	        [        R
                  R                  5      S5        U R                  [        R
                  R                  S   R                  S5        U R                  [        R
                  R                  S   R                  0 5        U R                   R                  [        SS9  [        SSSS9nU R                  US5        U R                  [	        [        R
                  R                  5      S5        U R                  [        R
                  R                  S   R                  S5        U R                  [        R
                  R                  S   R                  SSS.5        g)z]Testing FunctionSpy calls with call_original=True and function
with all mixed argument types
Tr   ry  r  )r'   unusedr  rF   r   r$   )r&   r'   r  r'   r  )ry  N)r   r   r(   r   r   r   r   r   r   r,   r.   rb  s     r   /test_call_with_original_true_and_function_mixed@FunctionSpyTests.test_call_with_original_true_and_function_mixed  s    	7$7r$/%W[[../3**1-22B7**1-447
 	 	;d;R2&%[__223Q7..q166A..q188"===rR5%]..445q9**00388%@**003::=
 	r!   c                 T   [        5       nU R                  R                  UR                  SS9  UR                  5       nU R	                  US5        U R	                  [        UR                  R                  5      S5        U R                  UR                  R                  SSS95        g)zKTesting FunctionSpy calls with call_original=True and bound method
        Tr   r   rF   rG   r+   N)	r	   r   r   r(   r   r   r   r   rh  ri  s      r   -test_call_with_original_true_and_bound_method>FunctionSpyTests.test_call_with_original_true_and_bound_method  s     k3;;d;#S[[../344qA4>?r!   c                    [        5       nU R                  R                  UR                  SS9  UR                  SS5      nU R	                  US5        U R	                  [        UR                  R                  5      S5        U R	                  UR                  R                  S   R                  S5        U R	                  [        UR                  R                  S   R                  5      S5        g	)
zaTesting FunctionSpy calls with call_original=True and bound method
with all positional arguments
Tr   ry  r     rF   r   r  N)	r	   r   r   r,   r   r   r   r   r   ri  s      r   2test_call_with_original_true_and_bound_method_argsCFunctionSpyTests.test_call_with_original_true_and_bound_method_args  s     k3??$?R($S__223Q7..q166AS__2215<<=qAr!   c                    [        5       nU R                  R                  UR                  SS9  UR                  SS5      nU R	                  US5        U R	                  [        UR                  R                  5      S5        U R	                  UR                  R                  S   R                  S5        U R	                  UR                  R                  S   R                  SSS	.5        g
)zTesting FunctionSpy calls with call_original=True and bound method
with all positional arguments in place of keyword arguments
Tr   ry  r  r  rF   r   r$   r+   Nr  ri  s      r   =test_call_with_original_true_and_bound_method_args_for_kwargsNFunctionSpyTests.test_call_with_original_true_and_bound_method_args_for_kwargs  s     k3;;d;R$$S[[../3**1-22B7**1-447
 	r!   c                    [        5       nU R                  R                  UR                  SS9  UR                  SSS9nU R	                  US5        U R	                  [        UR                  R                  5      S5        U R	                  [        UR                  R                  S   R                  5      S5        U R	                  UR                  R                  S   R                  SSS.5        g	)
z^Testing FunctionSpy calls with call_original=True and bound method
with all keyword arguments
Tr   ry  r  r+   r  rF   r   Nr  ri  s      r   4test_call_with_original_true_and_bound_method_kwargsEFunctionSpyTests.test_call_with_original_true_and_bound_method_kwargs  s     k3;;d;rR($S[[../3S[[..q1667;**1-447
 	r!   c                 l   U R                   R                  [        R                  SS9  [        5       nUR                  5       nU R	                  US5        U R	                  [        [        R                  R                  5      S5        U R                  [        R                  R                  SSS95        g)zMTesting FunctionSpy calls with call_original=True and unbound method
        Tr   r   rF   rG   r+   N	r   r   r	   r(   r   r   r   r   rh  ri  s      r   /test_call_with_original_true_and_unbound_method@FunctionSpyTests.test_call_with_original_true_and_unbound_method  s     	9,,DAk#Y..445q9	))::Q!:DEr!   c                 t   U R                   R                  [        R                  SS9  [        5       nUR                  SS5      nU R	                  US5        U R	                  [        [        R                  R                  5      S5        U R                  [        R                  R                  SS5      5        g)zcTesting FunctionSpy calls with call_original=True and unbound
method with all positional arguments
Tr   ry  r  r  rF   N)	r   r   r	   r,   r   r   r   r   rh  ri  s      r   4test_call_with_original_true_and_unbound_method_argsEFunctionSpyTests.test_call_with_original_true_and_unbound_method_args  s     	900EkR($Y228891=	-->>r2FGr!   c                 p   U R                   R                  [        R                  SS9  [        5       nUR                  SS5      nU R	                  US5        U R	                  [        [        R                  R                  5      S5        U R                  [        R                  R                  SSS95        g)	zTesting FunctionSpy calls with call_original=True and unbound
method with all positional arguments in place of keyword arguments
Tr   ry  r  r  rF   r+   Nr  ri  s      r   ?test_call_with_original_true_and_unbound_method_args_for_kwargsPFunctionSpyTests.test_call_with_original_true_and_unbound_method_args_for_kwargs'  s     	9,,DAkR$$Y..445q9	))::R2:FGr!   c                    U R                   R                  [        R                  SS9  [        5       nUR                  SSS9nU R	                  US5        U R	                  [        [        R                  R                  5      S5        U R	                  [        [        R                  R                  S   R                  5      S5        U R                  [        R                  R                  SSS95        g	)
z`Testing FunctionSpy calls with call_original=True and unbound method
with all keyword arguments
Tr   ry  r  r+   r  rF   r   N)
r   r   r	   r(   r   r   r   r   r   rh  ri  s      r   6test_call_with_original_true_and_unbound_method_kwargsGFunctionSpyTests.test_call_with_original_true_and_unbound_method_kwargs4  s     	9,,DAkrR($Y..445q9Y..44Q7<<=qA	))::R2:FGr!   c                 b   U R                   R                  [        R                  SS9  [        R                  " 5       nU R	                  US5        U R	                  [        [        R                  R                  5      S5        U R                  [        R                  R                  SSS95        g)	zATesting FunctionSpy calls with call_original=True and classmethodTr   ry  rF   rG   rq  r+   N)	r   r   r	   r   r   r   r   r   rh  rb  s     r   ,test_call_with_original_true_and_classmethod=FunctionSpyTests.test_call_with_original_true_and_classmethodB  s    922$G((*$Y44::;Q?	//@@1@JKr!   c                    U R                   R                  [        R                  SS9  [        R                  " SS5      nU R	                  US5        U R	                  [        [        R                  R                  5      S5        U R	                  [        R                  R                  S   R                  S5        U R	                  [        [        R                  R                  S   R                  5      S5        g	)
z`Testing FunctionSpy calls with call_original=True and classmethod
with all positional arguments
Tr   ry  r  r]  rF   r   r  N)	r   r   r	   class_do_math_posr   r   r   r   r   rb  s     r   1test_call_with_original_true_and_classmethod_argsBFunctionSpyTests.test_call_with_original_true_and_classmethod_argsK  s     	966dK,,R4%Y88>>?C44::1=BBHMY88>>qAHHI1Mr!   c                    U R                   R                  [        R                  SS9  [        R                  " SS5      nU R	                  US5        U R	                  [        [        R                  R                  5      S5        U R	                  [        R                  R                  S   R                  S5        U R	                  [        R                  R                  S   R                  SSS	.5        g
)z~Testing FunctionSpy calls with call_original=True and classmethod
with all positional arguments in place of keyword arguments
Tr   ry  r  r]  rF   r   r$   r+   N	r   r   r	   r   r   r   r   r   r   rb  s     r   <test_call_with_original_true_and_classmethod_args_for_kwargsMFunctionSpyTests.test_call_with_original_true_and_classmethod_args_for_kwargsW  s     	922$G((R0%Y44::;Q?0066q9>>C0066q9@@C
 	r!   c                    U R                   R                  [        R                  SS9  [        R                  " SSS9nU R	                  US5        U R	                  [        [        R                  R                  5      S5        U R	                  [        [        R                  R                  S   R                  5      S5        U R	                  [        R                  R                  S   R                  SSS.5        g	)
z]Testing FunctionSpy calls with call_original=True and classmethod
with all keyword arguments
Tr   ry  r  r+   r]  rF   r   Nr  rb  s     r   3test_call_with_original_true_and_classmethod_kwargsDFunctionSpyTests.test_call_with_original_true_and_classmethod_kwargsf  s     	922$G((24%Y44::;Q?Y44::1=BBCQG0066q9@@C
 	r!   c                    ^ 0 mU4S jnU R                   R                  U5        U" 5         U R                  UR                  5        U R	                  TSS05        g)zJTesting FunctionSpy calls for inline function using a closure's
variables
c                     > ST S'   g NTcalledr$   r3  s   r   r   PFunctionSpyTests.test_call_with_inline_function_using_closure_vars.<locals>.func{  s    AhKr!   r  TNr   r   r   r  r   r1   r   r3  s     @r   1test_call_with_inline_function_using_closure_varsBFunctionSpyTests.test_call_with_inline_function_using_closure_varsu  sM     	 	4 $Xt,-r!   c                    ^ 0 mU4S jnU R                   R                  U5        U" SSSS9  U R                  UR                  5        U R	                  TSS05        g)	zfTesting FunctionSpy calls for inline function using a closure's
variables and function with arguments
c                    > X-   U-   TS'   g )Ncall_resultr$   )r&   r'   r2  r3  s      r   r   YFunctionSpyTests.test_call_with_inline_function_using_closure_vars_and_args.<locals>.func  s     uqyAmr!   rF   rG   r   rE  r     Nr  r  s     @r   :test_call_with_inline_function_using_closure_vars_and_argsKFunctionSpyTests.test_call_with_inline_function_using_closure_vars_and_args  sS     	) 	4 QQ$]A./r!   c                     S nU R                   R                  U5        U" 5       nU R                  UR                  5        U R	                  USS05        g)zRTesting FunctionSpy calls for function providing variables for an
inline function
c                  &   ^ 0 mU4S jn U " 5         T$ )Nc                     > ST S'   g r  r$   r  s   r   inline_funcbFunctionSpyTests.test_call_with_function_providing_closure_vars.<locals>.func.<locals>.inline_func  s    "(r!   r$   )r  r3  s    @r   r   MFunctionSpyTests.test_call_with_function_providing_closure_vars.<locals>.func  s    A# MHr!   r  TNr  r  s      r   .test_call_with_function_providing_closure_vars?FunctionSpyTests.test_call_with_function_providing_closure_vars  sG    	 	4 F$Xt,-r!   c                     S nU R                   R                  U5        U" S5      nU R                  US5        U R                  UR                  5        g)zOTesting FunctionSpy calls with an inline function accessing
parent's arguments
c                    ^  U 4S jng)Nc                     > [        T 5        g r#   )print)args   r   r  iFunctionSpyTests.test_call_with_function_providing_closure_access_args.<locals>.func.<locals>.inline_func  s
    c
r!   {   r$   )r  r  s   ` r   r   TFunctionSpyTests.test_call_with_function_providing_closure_access_args.<locals>.func  s     r!   r   r  N)r   r   r   r   r  r  s      r   5test_call_with_function_providing_closure_access_argsFFunctionSpyTests.test_call_with_function_providing_closure_access_args  sD    	 	4 HC $r!   c                     [        5       nU R                  R                  UR                  5        UR                  5       nU R	                  UR                  R
                  5        U R                  U/ SQ5        g)zYTesting FunctionSpy calls for bound method using a list
comprehension referencing 'self'
rG   r   r  N)rA   r   r   r   r   r  r   ri  s      r   <test_call_with_bound_method_with_list_comprehension_and_selfMFunctionSpyTests.test_call_with_bound_method_with_list_comprehension_and_self  sP     m388$(+r!   c                     U R                   R                  [        R                  5        [        5       nUR                  5       nU R	                  UR                  R
                  5        U R                  U/ SQ5        g)z[Testing FunctionSpy calls for unbound method using a list
comprehension referencing 'self'
r  N)r   r   rA   r   r   r  r   ri  s      r   >test_call_with_unbound_method_with_list_comprehension_and_selfOFunctionSpyTests.test_call_with_unbound_method_with_list_comprehension_and_self  sR     	;++,m(+r!   c                     U R                   R                  [        R                  5        [        R                  5       nU R	                  [        R                  R
                  5        U R                  U/ SQ5        g)zWTesting FunctionSpy calls for classmethod using a list
comprehension referencing 'cls'
r  N)r   r   rA   rR   r   r  r   rb  s     r   ;test_call_with_classmethod_with_list_comprehension_and_selfLFunctionSpyTests.test_call_with_classmethod_with_list_comprehension_and_self  sR     	;112'')..556+r!   c                     U R                   R                  [        SS9  [        R                  SS5      nU R	                  US5        U R                  [        R                  5        g)zWTesting FunctionSpy.call_original with spy on function set up using
call_original=True
Tr   ry  r  r  Nr   r   r(   r   r   r   r  rb  s     r   .test_call_original_with_orig_func_and_function?FunctionSpyTests.test_call_original_with_orig_func_and_function  sV     	7)- 	 	/ &&r2.%(r!   c                    [        5       nU R                  R                  UR                  SS9  UR                  R	                  S5      nU R                  US5        U R                  UR                  R                  5        g)z[Testing FunctionSpy.call_original with spy on bound method set up
using call_original=True
Tr   rq  r  N)rA   r   r   rH   r   r   r   r  ri  s      r   2test_call_original_with_orig_func_and_bound_methodCFunctionSpyTests.test_call_original_with_orig_func_and_bound_method  si     m3;;)- 	 	/ **1-#++,r!   c                 `   U R                   R                  [        R                  SS9  [        5       nUR                  R	                  US5      nU R                  US5        U R                  [        R                  R                  5        U R                  UR                  R                  5        g)z]Testing FunctionSpy.call_original with spy on unbound method set up
using call_original=True
Tr   rq  r  N)r   r   rA   rH   r   r   r   r  ri  s      r   4test_call_original_with_orig_func_and_unbound_methodEFunctionSpyTests.test_call_original_with_orig_func_and_unbound_method  s     	;..)- 	 	/ m**32#,,334++,r!   c                    U R                   R                  [        R                  SS9  [        R                  R	                  S5      nU R                  US5        U R                  [        R                  R                  5        g)zZTesting FunctionSpy.call_original with spy on classmethod set up
using call_original=True
Tr   rq  r  N)r   r   rA   rP   r   r   r   r  rb  s     r   1test_call_original_with_orig_func_and_classmethodBFunctionSpyTests.test_call_original_with_orig_func_and_classmethod   sh     	;44)- 	 	/ **88;#2299:r!   c                     U R                   R                  [        5        [        R                  SS5      nU R	                  US5        U R                  [        R                  5        g)zXTesting FunctionSpy.call_original with spy on function set up using
call_original=False
ry  r  r  Nr!  rb  s     r   ,test_call_original_with_no_func_and_function=FunctionSpyTests.test_call_original_with_no_func_and_function  sJ     	7#&&r2.%(r!   c                    [        5       nU R                  R                  UR                  5        UR                  R	                  SS5      nU R                  US5        U R                  UR                  R                  5        g)z\Testing FunctionSpy.call_original with spy on bound method set up
using call_original=False
ry  r  r  N)r	   r   r   r(   r   r   r   r  ri  s      r   0test_call_original_with_no_func_and_bound_methodAFunctionSpyTests.test_call_original_with_no_func_and_bound_method  s_     k3;;'**2r2$++,r!   c                 d   U R                   R                  [        R                  5        [        5       nUR                  R	                  USS5      nU R                  US5        U R                  [        R                  R                  5        U R                  UR                  R                  5        g)z^Testing FunctionSpy.call_original with spy on unbound method set up
using call_original=False
ry  r  r  N)r   r   r	   r(   r   r   r   r  ri  s      r   2test_call_original_with_no_func_and_unbound_methodCFunctionSpyTests.test_call_original_with_no_func_and_unbound_method#  s}     	9,,-k**3B7$**112++,r!   c                    U R                   R                  [        R                  5        [        R                  R	                  SS5      nU R                  US5        U R                  [        R                  R                  5        g)z[Testing FunctionSpy.call_original with spy on classmethod set up
using call_original=False
ry  r  r]  N)r   r   r	   r   r   r   r   r  rb  s     r   /test_call_original_with_no_func_and_classmethod@FunctionSpyTests.test_call_original_with_no_func_and_classmethod0  s^     	9223((66r2>%00778r!   c                     U R                   R                  [        [        S9  [        R	                  SS5      nU R                  US5        U R                  [        R                  5        g)zOTesting FunctionSpy.call_original with spy on function set up using
call_fake=
r   ry  r  r  N)r   r   r(   r2   r   r   r   r  rb  s     r   .test_call_original_with_fake_func_and_function?FunctionSpyTests.test_call_original_with_fake_func_and_function;  sV     	7%1 	 	3 &&r2.%(r!   c                    [        5       nU R                  R                  UR                  [        S9  UR                  R                  SS5      nU R                  US5        U R                  UR                  R                  5        g)zSTesting FunctionSpy.call_original with spy on bound method set up
using call_fake=
r   ry  r  r  N)	r	   r   r   r(   r2   r   r   r   r  ri  s      r   2test_call_original_with_fake_func_and_bound_methodCFunctionSpyTests.test_call_original_with_fake_func_and_bound_methodG  sk     k3;;%1 	 	3 **2r2$++,r!   c                 j   U R                   R                  [        R                  [        S9  [        5       nUR                  R                  USS5      nU R                  US5        U R                  [        R                  R                  5        U R                  UR                  R                  5        g)zUTesting FunctionSpy.call_original with spy on unbound method set up
using call_fake=
r   ry  r  r  N)	r   r   r	   r(   r2   r   r   r   r  ri  s      r   4test_call_original_with_fake_func_and_unbound_methodEFunctionSpyTests.test_call_original_with_fake_func_and_unbound_methodT  s     	9,,%1 	 	3 k**3B7$**112++,r!   c                    U R                   R                  [        R                  [        S9  [        R                  R                  SS5      nU R                  US5        U R                  [        R                  R                  5        g)zRTesting FunctionSpy.call_original with spy on classmethod set up
using call_fake=
r   ry  r  r]  N)	r   r   r	   r   r6   r   r   r   r  rb  s     r   1test_call_original_with_fake_func_and_classmethodBFunctionSpyTests.test_call_original_with_fake_func_and_classmethodb  sj     	922%7 	 	9 ((66r2>%00778r!   c                 *   U R                   R                  [        R                  SS9  [        5       n[        R
                  " S5      nU R                  [        U5         UR                  R                  S5        SSS5        g! , (       d  f       g= f)zvTesting FunctionSpy.call_original with spy on unbound method set up
using call_original=True without passing instance
Tr   zThe first argument to add_one.call_original() must be an instance of kgb.tests.test_function_spy.AdderObject, since this is an unbound method.rq  N)	r   r   rA   rH   reescaper  	TypeErrorr   )r1   rp   messages      r   2test_call_original_with_unbound_method_no_instanceCFunctionSpyTests.test_call_original_with_unbound_method_no_instancen  sr     	;..)- 	 	/ m))$
 ##Iw7KK%%a( 877s   B
Bc                    [        5       nU R                  R                  UR                  5        U R	                  UR                  R
                  5        UR                  SS5        U R                  UR                  R
                  5        g)zTesting FunctionSpy.calledry  r  N)r	   r   r   r(   r   r  r   r1   rp   s     r   test_calledFunctionSpyTests.test_called  s[    k3;;'++,B**+r!   c                    [        5       nU R                  R                  UR                  5        UR                  SS5        UR                  SS5        U R	                  [        UR                  R                  5      S5        UR                  R                  nU R                  US5        U R                  UR                  SSS95        g)zTesting FunctionSpy.last_callry  r  r  rG   Nr+   )r	   r   r   r(   r   r   r   	last_callr   r   r  r1   rp   rQ  s      r   test_last_callFunctionSpyTests.test_last_call  s    k3;;'BBS[[../3KK))	It,	--b-9:r!   c                    [        5       nU R                  R                  UR                  5        U R	                  [        UR                  R                  5      S5        UR                  R                  nU R	                  US5        g)z2Testing FunctionSpy.last_call on uncalled functionr   N)r	   r   r   r(   r   r   r   rQ  rR  s      r   test_last_call_with_no_calls-FunctionSpyTests.test_last_call_with_no_calls  s]    k3;;'S[[../3KK))	D)r!   c                    [        [        [        R                  5      nU R                  R                  [        S S9nU R                  [        [        S5      5        U R                  [        R                  U5        U R                  [        5       S5        UR                  5         U R                  [        [        S5      5        U R                  [        [        [        R                  5      U5        U R                  [        5       S5        g)zTesting FunctionSpy.unspyc                      g)Nspy!r$   r$   r!   r   r<  -FunctionSpyTests.test_unspy.<locals>.<lambda>  s    fr!   r   r   rZ  r8   N)r   r9   r   FUNC_CODE_ATTRr   r   r   r   r   r   rQ  r   )r1   	orig_coder   s      r   
test_unspyFunctionSpyTests.test_unspy  s    -{/I/IJ	kk  !2n M 159:*..4*,f5		!2E:;!2!,!;!;="	$ 	*,g6r!   c                 b   [        5       nUR                  R                  R                  5       nU R                  R                  UR                  5      nU R                  UR                  R                  U5        UR                  5         U R                  UR                  R                  U5        g)z*Testing FunctionSpy.unspy and bound methodN	r	   r(   __dict__copyr   r   r   rQ  r   )r1   rp   	func_dictr   s       r   test_unspy_and_bound_method,FunctionSpyTests.test_unspy_and_bound_method  sv    kKK((--/	kk  -CKK00)<		--y9r!   c                 z    " S S[         5      nU" 5       nUR                  R                  R                  5       nU R                  R                  UR                  5      nU R                  UR                  R                  U5        UR                  5         U R                  UR                  R                  U5        g)zYTesting FunctionSpy.unspy with a bound method on a class containing
a custom __setattr__
c                        \ rS rSrS rS rSrg)RFunctionSpyTests.test_unspy_with_bound_method_and_custom_setattr.<locals>.MyObjecti  c                      er#   r$   r  s      r   r  ^FunctionSpyTests.test_unspy_with_bound_method_and_custom_setattr.<locals>.MyObject.__setattr__  r  r!   c                     g r#   r$   rd   s    r   r   VFunctionSpyTests.test_unspy_with_bound_method_and_custom_setattr.<locals>.MyObject.foo  r   r!   r$   Nr
  r$   r!   r   r   ri    r  r!   r   N)	r   r   rb  rc  r   r   r   rQ  r   )r1   r   rp   rd  r   s        r   /test_unspy_with_bound_method_and_custom_setattr@FunctionSpyTests.test_unspy_with_bound_method_and_custom_setattr  s    	v 	 jGG$$))+	kk  )CGG,,i8		))95r!   c                 n   [         R                  R                  R                  5       nU R                  R                  [         R                  5      nU R                  [         R                  R                  U5        UR                  5         U R                  [         R                  R                  U5        g)z,Testing FunctionSpy.unspy and unbound methodNra  r1   rd  r   s      r   test_unspy_and_unbound_method.FunctionSpyTests.test_unspy_and_unbound_method  sw    %%..335	kk  !2!23I--66	B		**33Y?r!   c                 n   [         R                  R                  R                  5       nU R                  R                  [         R                  5      nU R                  [         R                  R                  U5        UR                  5         U R                  [         R                  R                  U5        g)z*Testing FunctionSpy.unspy with classmethodN)	r	   r   rb  rc  r   r   r   rQ  r   rq  s      r   test_unspy_with_classmethod,FunctionSpyTests.test_unspy_with_classmethod  sw    ++4499;	kk  !8!89I33<<iH		00999Er!   c                 b    " S S[         5      n " S SU5      nUR                  R                  R                  5       nUR                  R                  R                  5       nU R                  R                  UR                  5      nU R                  UR                  R                  U5        U R                  UR                  R                  U5        UR                  5         U R                  UR                  R                  U5        U R                  UR                  R                  U5        g)z:Testing FunctionSpy.unspy with classmethod on parent classc                   $    \ rS rSr\S 5       rSrg)HFunctionSpyTests.test_unspy_with_classmethod_on_parent.<locals>.MyParenti  c                     g r#   r$   rd   s    r   r   LFunctionSpyTests.test_unspy_with_classmethod_on_parent.<locals>.MyParent.foo  r   r!   r$   Nr   r$   r!   r   r   ry    r   r!   r   c                       \ rS rSrSrg)HFunctionSpyTests.test_unspy_with_classmethod_on_parent.<locals>.MyObjecti  r$   Nr_   r$   r!   r   r   r}    r   r!   r   N	r   r   rb  rc  r   r   r   r   rQ  r1   r   r   parent_func_dictobj_func_dictr   s         r   %test_unspy_with_classmethod_on_parent6FunctionSpyTests.test_unspy_with_classmethod_on_parent  s    	v 	
	x 	 $<<00557 --224kk  .HLL11=A..0@A		..>..0@Ar!   c                 `    " S S[         5      n " S SU5      nUR                  R                  R                  5       nUR                  R                  R                  5       nU R                  R                  UR                  US9nU R                  UR                  R                  U5        U R                  UR                  R                  U5        UR                  5         U R                  UR                  R                  U5        U R                  UR                  R                  U5        g)z=Testing FunctionSpy.unspy with unbound method on parent classc                       \ rS rSrS rSrg)KFunctionSpyTests.test_unspy_with_unbound_method_on_parent.<locals>.MyParenti  c                     g r#   r$   rd   s    r   r   OFunctionSpyTests.test_unspy_with_unbound_method_on_parent.<locals>.MyParent.foo  r   r!   r$   Nr   r$   r!   r   r   r    r   r!   r   c                       \ rS rSrSrg)KFunctionSpyTests.test_unspy_with_unbound_method_on_parent.<locals>.MyObjecti  r$   Nr_   r$   r!   r   r   r    r   r!   r   r   Nr~  r  s         r   (test_unspy_with_unbound_method_on_parent9FunctionSpyTests.test_unspy_with_unbound_method_on_parent  s    	v 		x 	 $<<00557 --224kk  X >HLL11=A..0@A		..>..0@Ar!   c                    [        5       nU R                  R                  UR                  US9nUR	                  5         U R                  [        UR                  S5      5        U R                  SUR                  5        S[        l
        UR                  nUR                  nU R                  X45        U R                  U" 5       S5        U R                  U" 5       S5        U R                  U" 5       S5        U R                  U" 5       S5        U R                  UR                  5       S5        U R                  UR                  5       S5        g)	zTTesting FunctionSpy.unspy with slippery function generated by
spied-on bound method
r   r   r|   r   rF   rG   r   N)rx   r   r   r|   rQ  r   r   assertNotInrb  ra   rr   r   r   )r1   rp   r   r   r   s        r   %test_unspy_with_slippery_bound_method6FunctionSpyTests.test_unspy_with_slippery_bound_method  s    !"kk  C 8		e45CLL1  & 	!$!$!$!$ 	**r!   c                    [        5       nU R                  R                  UR                  5        UR                  SSS9  UR                  SSS9  U R	                  UR                  R                  SSS95        U R	                  UR                  R                  SSS95        U R	                  UR                  R                  SSS95        U R	                  UR                  R                  SSS95        U R                  UR                  R                  SS5      5        U R                  UR                  R                  SS5      5        U R                  UR                  R                  SSS95        g	)
zTesting FunctionSpy.called_withrF   rG   r  r   r  r+   rq  r  Nr	   r   r   r.   r   r  r   rM  s     r   test_called_with!FunctionSpyTests.test_called_with-  s5   k3,,-!q!!q!))55a15=>))55a15=>))55Q5?@))55Q5?@**66q!<=**66q!<=**66qA6>?r!   c                 <   [        5       nU R                  R                  UR                  5        UR                  SSS9  UR                  SSS9  U R	                  UR                  R                  SSS95        U R	                  UR                  R                  SSS95        U R	                  UR                  R                  SSS95        U R	                  UR                  R                  SSS95        U R                  UR                  R                  SSS95        g	)
z5Testing FunctionSpy.called_with and keyword argumentsrF   rG   r+   r   r  r  rq  r  Nr  rM  s     r   !test_called_with_and_keyword_args2FunctionSpyTests.test_called_with_and_keyword_args=  s    k3,,-A#A#))55a15=>))55a15=>))55Q5?@))55Q5?@**66qA6>?r!   c                    [        5       nU R                  R                  UR                  5        UR                  SS5        UR                  SS5        U R	                  UR                  R                  S5      5        U R	                  UR                  R                  S5      5        U R                  UR                  R                  S5      5        U R                  UR                  R                  SSS5      5        g)5Testing FunctionSpy.called_with and partial argumentsrF   rG   r   r  Nr  rM  s     r   !test_called_with_and_partial_args2FunctionSpyTests.test_called_with_and_partial_argsK  s    k3,,-!Q!Q))55a89))55a89**66q9:**66q!Q?@r!   c                    [        5       nU R                  R                  UR                  5        UR                  SSS9  UR                  SSS9  U R	                  UR                  R                  S5      5        U R	                  UR                  R                  SS95        U R	                  UR                  R                  S5      5        U R	                  UR                  R                  SS95        U R	                  UR                  R                  SSS95        U R	                  UR                  R                  SSS95        U R                  UR                  R                  SS5      5        U R                  UR                  R                  SS5      5        U R                  UR                  R                  SS95        U R                  UR                  R                  SSSS95        U R                  UR                  R                  SSS95        U R                  UR                  R                  SSS95        g	)
=Testing FunctionSpy.called_with and partial keyword argumentsrF   rG   r+   r   r  r  r?  r;  Nr  rM  s     r   #test_called_with_and_partial_kwargs4FunctionSpyTests.test_called_with_and_partial_kwargsX  s   k3,,-A#A#))55a89))555:;))55a89))555:;))55Q5?@))55Q5?@**66q!<=**66q!<=**666;<**66a16EF**66a6@A**66a6@Ar!   c                 N   [        5       nU R                  R                  UR                  5        UR                  SS5        UR                  SS5        U R	                  UR                  R                  SSS95        U R                  UR                  R                  SSS95        g)z$Testing FunctionSpy.last_called_withrF   rG   r   r  r?  r  N)r	   r   r   r.   r   rh  r   rM  s     r   test_last_called_with&FunctionSpyTests.test_last_called_withm  s    k3,,-!Q!Q**;;A;CD))::1:BCr!   c                    [        5       nU R                  R                  UR                  5        UR                  SSS9  UR                  SSS9  U R	                  UR                  R                  SSS95        U R                  UR                  R                  SSS95        U R                  UR                  R                  SSSS95        g)	z:Testing FunctionSpy.last_called_with and keyword argumentsrF   rG   r+   r   r  r  r'   r2  Nr	   r   r   r.   r   rh  r   rM  s     r   &test_last_called_with_and_keyword_args7FunctionSpyTests.test_last_called_with_and_keyword_argsx  s    k3,,-A#A#))::1:BC**;;A;CD**;;Aa;HIr!   c                    [        5       nU R                  R                  UR                  5        UR                  SS5        UR                  SS5        U R	                  UR                  R                  S5      5        U R	                  UR                  R                  SSS95        U R                  UR                  R                  SSSS95        U R                  UR                  R                  SSS95        g)	r  rF   rG   r   r  r  rq  r  Nr  rM  s     r   &test_last_called_with_and_partial_args7FunctionSpyTests.test_last_called_with_and_partial_args  s    k3,,-!Q!Q))::1=>))::1:BC**;;Aa;HI**;;A;CDr!   c                 2   [        5       nU R                  R                  UR                  5        UR                  SSS9  UR                  SSS9  U R	                  UR                  R                  S5      5        U R	                  UR                  R                  SS95        U R                  UR                  R                  SS95        U R                  UR                  R                  SS95        U R                  UR                  R                  SS95        U R                  UR                  R                  SS5      5        U R                  UR                  R                  SSSS95        U R                  UR                  R                  SSS	95        g
)r  rF   rG   r+   r   r  r  r?  r;  )r&   r2  Nr  rM  s     r   (test_last_called_with_and_partial_kwargs9FunctionSpyTests.test_last_called_with_and_partial_kwargs  sU   k3,,-A#A#))::1=>))::Q:?@**;;a;@A**;;a;@A**;;a;@A**;;AqAB**;;a1;JK**;;a1;EFr!   c                    [        5       nU R                  R                  UR                  5        UR                  SS5        UR                  SS5        U R	                  UR                  R                  S5      5        U R	                  UR                  R                  S5      5        U R                  UR                  R                  S5      5        U R                  UR                  R                  S5      5        g)zTesting FunctionSpy.returnedrF   rG   r   r     ry  N)r	   r   r   r(   r   returnedr   rM  s     r   test_returnedFunctionSpyTests.test_returned  s    k3;;'AqAq,,Q/0,,Q/0--b12--d34r!   c                    [        5       nU R                  R                  UR                  5        UR                  SS5        UR                  SS5        U R	                  UR                  R                  S5      5        U R                  UR                  R                  S5      5        U R	                  UR                  R                  S5      5        g)z!Testing FunctionSpy.last_returnedrF   rG   r   r  r  N)r	   r   r   r(   r   last_returnedr   rM  s     r   test_last_returned#FunctionSpyTests.test_last_returned  s    k3;;'AqAq2215611!4522489r!   c                    [        5       nU R                  R                  UR                  5        U R	                  [
        5         UR                  SS5        SSS5        U R                  UR                  R                  [
        5      5        U R                  UR                  R                  [        5      5        U R                  UR                  R                  S5      5        g! , (       d  f       N= f)zTesting FunctionSpy.raisedrF   r&   N)
r	   r   r   r(   r   rH  r   raisedr   r   rM  s     r   test_raisedFunctionSpyTests.test_raised  s    k3;;'y)KK3 * 	**956++J78++D12 *)s   C''
C5c                 h   [        5       nU R                  R                  UR                  5        U R	                  [
        5         UR                  SS5        SSS5        U R                  UR                  R                  [
        5      5        U R                  UR                  R                  S5      5        UR                  SS5        U R                  UR                  R                  [
        5      5        U R                  UR                  R                  S5      5        g! , (       d  f       N= f)zTesting FunctionSpy.last_raisedrF   r&   Nr  )	r	   r   r   r(   r   rH  r   last_raisedr   rM  s     r   test_last_raised!FunctionSpyTests.test_last_raised  s    k3;;'y)KK3 * 	//	:;0067Aq00;<//56 *)s   D##
D1c                 B   [        5       nU R                  R                  UR                  5        U R	                  [
        5         UR                  SS5        SSS5        U R                  UR                  R                  [
        S[        R                  -  5      5        U R                  UR                  R                  [        S[        R                  -  5      5        U R                  UR                  R                  [
        S5      5        g! , (       d  f       N= f)z'Testing FunctionSpy.raised_with_messagerF   r&   N1unsupported operand type(s) for +: 'int' and '%s')r	   r   r   r(   r   rH  r   raised_with_messager   rV   r   r   rM  s     r   test_raised_with_message)FunctionSpyTests.test_raised_with_message  s    k3;;'y)KK3 * 	77?  !" 	# 	88?  !" 	# 	88DIJ *)s   D
Dc                    [        5       nU R                  R                  UR                  5        U R	                  [
        5         UR                  SS5        SSS5        U R                  UR                  R                  [
        S[        R                  -  5      5        U R                  UR                  R                  [
        S5      5        g! , (       d  f       N~= f)z,Testing FunctionSpy.last_raised_with_messagerF   r&   Nr  )r	   r   r   r(   r   rH  r   last_raised_with_messager   rV   r   rM  s     r   test_last_raised_with_message.FunctionSpyTests.test_last_raised_with_message  s    k3;;'y)KK3 * 	<<?  !" 	# 	==iNO *)s   C
Cc                    [        5       nU R                  R                  UR                  5        UR                  SS5        U R	                  [        UR                  R                  5      S5        U R	                  UR                  R                  UR                  R                  S   5        U R                  UR                  R                  5        UR                  R                  5         U R	                  [        UR                  R                  5      S5        U R                  UR                  R                  5        U R                  UR                  R                  5        g)zTesting FunctionSpy.reset_callsrF   rG   rg  r   N)r	   r   r   r(   r   r   r   rQ  r   r  reset_callsr   r   rM  s     r   test_reset_calls!FunctionSpyTests.test_reset_calls  s    k3;;'AqS[[../3..0A0A"0EF**+!S[[../3#++//0++,r!   c                     U R                   R                  [        5        U R                  [	        [        S5      5        U R                  [        [        R                  5      S5        g)zTesting FunctionSpy.__repr__r   z%<Spy for something_awesome (0 calls)>N)r   r   r9   r   r   reprr   rd   s    r   	test_reprFunctionSpyTests.test_repr  sG    ,- 159:.223?	Ar!   c                     U R                   R                  [        5        U R                  [	        [        R
                  5      S5        g)z)Testing FunctionSpy.__repr__ and functionz$<Spy for function do_math (0 calls)>N)r   r   r(   r   r  r   rd   s    r   test_repr_and_function'FunctionSpyTests.test_repr_and_function  s1    7#gkk*?	Ar!   c                     [        5       nU R                  R                  UR                  5        UR                  5         U R	                  [        UR                  R                  5      SU-  5        g)z-Testing FunctionSpy.__repr__ and bound methodz7<Spy for bound method MathClass.do_math of %r (1 call)>N)r	   r   r   r(   r   r  r   rM  s     r   test_repr_and_bound_method+FunctionSpyTests.test_repr_and_bound_method  sR    k3;;'ckkoo.+-01	2r!   c                     U R                   R                  [        R                  5        U R	                  [        [        R                  R                  5      S[        -  5        g)z/Testing FunctionSpy.__repr__ and unbound methodz:<Spy for unbound method MathClass.do_math of %r (0 calls)>N)r   r   r	   r(   r   r  r   rd   s    r   test_repr_and_unbound_method-FunctionSpyTests.test_repr_and_unbound_method   sH    9,,-i//334,.78	9r!   c                     U R                   R                  [        R                  5        U R	                  [        [        R                  R                  5      S[        -  5        g)z-Testing FunctionSpy.__repr__ with classmethodz=<Spy for classmethod MathClass.class_do_math of %r (0 calls)>N)r   r   r	   r   r   r  r   rd   s    r   test_repr_with_classmethod+FunctionSpyTests.test_repr_with_classmethod(  sG    9223((,,-K	r!   c                    U R                   R                  [        5        [        R                  " [        5      u  pp4U R                  USS/5        U R                  US5        U R                  US5        U R                  US5        g)z9Testing FunctionSpy in inspect.getargspec() with functionr&   r'   r   r   rP  N)r   r   r(   inspectr   r   r1   r   varargskeywordsdefaultss        r   test_getargspec_with_function.FunctionSpyTests.test_getargspec_with_function1  so     	7#,3,>,>w,G)xSz*&)8,6*r!   c                 <   [        5       nU R                  R                  UR                  5        [        R
                  " UR                  5      u  p#pEU R                  U/ SQ5        U R                  US5        U R                  US5        U R                  US5        g)z=Testing FunctionSpy in inspect.getargspec() with bound methodr1   r&   r'   r   r   rP  N)r	   r   r   r(   r  r   r   r1   rp   r   r  r  r  s         r   !test_getargspec_with_bound_method2FunctionSpyTests.test_getargspec_with_bound_method<  s{     k3;;',3,>,>s{{,K)x12&)8,6*r!   c                 8   U R                   R                  [        R                  5        [        R
                  " [        R                  5      u  pp4U R                  U/ SQ5        U R                  US5        U R                  US5        U R                  US5        g)z?Testing FunctionSpy in inspect.getargspec() with unbound methodr  r   r   rP  N)r   r   r	   r(   r  r   r   r  s        r   #test_getargspec_with_unbound_method4FunctionSpyTests.test_getargspec_with_unbound_methodH  s|     	9,,- y001 	*x12&)8,6*r!   c                 <   [        5       nU R                  R                  UR                  5        [        R
                  " UR                  5      u  p#pEU R                  U/ SQ5        U R                  US5        U R                  US5        U R                  US5        g)z<Testing FunctionSpy in inspect.getargspec() with classmethod)r5   r&   r'   r   r   )rG   rq  N)r	   r   r   r   r  r   r   r  s         r    test_getargspec_with_classmethod1FunctionSpyTests.test_getargspec_with_classmethodT  s     k3,,- s001 	*x01&)8,6*r!   Nc                    S nS n[         R                  " 5          [         R                  " S[        5        U R                  R                  UUS9n[        U" 5       5      nU R                  U/ SQ5        UR                  5         U R                  R                  U5      n[        U" 5       5      nU R                  U/ SQ5        UR                  5         SSS5        g! , (       d  f       g= f)z-Testing FunctionSpy with a generator functionc               3   $   #    Sv   Sv   Sv   g 7f)Nr&   r'   r2  r$   r$   r!   r   _generator_functionCFunctionSpyTests.test_spy_on_generator.<locals>._generator_functiong       III   c               3   $   #    Sv   Sv   Sv   g 7f)Nxyzr$   r$   r!   r   _fake_generator?FunctionSpyTests.test_spy_on_generator.<locals>._fake_generatorl  r  r  errorr   )r  r  r  r;  N)	r   r   simplefilterDeprecationWarningr   r   r  r   rQ  )r1   r  r  r   resultss        r   test_spy_on_generator&FunctionSpyTests.test_spy_on_generatora  s    	
	
 $$&!!'+=>++$$%8/> % @C.01GWo6IIK++$$%89C.01GWo6IIK '&&s   B9C
C,r$   )returnN)vrV   rW   rX   rY   __doc__r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r   r#  r&  rR  r_  rd  rj  rm  rr  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  r  r  r"  r%  r(  r+  r.  r1  r4  r7  r:  r=  r@  rC  rJ  rN  rS  rV  r^  re  rn  rr  ru  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   r   r      s   /;E= =6I$
=E=$I0$4L!'3R4B?(
A341*P 6EFP	/	H
?";,9,@7D
>"	@>""	H
B!F
@B""
FHHHL
N.0.(%$	,	,,
)--
;	)
--	9
)--
9)$	,;*7 	:6(@FB*B(+<@ @AB*	D
JEG"5
:
37 K$P-AA	29 + + 	+ 	+ 	+ 	+ 
+ 
+r!   r   rP  )rG   )(
__future__r   r   r  rF  r   r  r   r   r   
contextlibr   
kgb.errorsr   r   kgb.pycompatr   kgb.signaturer   kgb.tests.baser	   r
   r   r   has_getfullargspecr    r(   r,   r.   r2   r6   r9   r<   r>   r   rA   r]   ra   rx   r   r$   r!   r   <module>r
     s    '   	 
     % B " % . ,/W&67 ,  & 0	K 	F * ux ur!   