
    =eV                     r   d dl Z d dlZd dlmZ d dlZd dlmZ d dlmZm	Z	 d dl
mZ d dlmZmZmZmZmZmZmZmZmZmZmZ dZej        e         Zdez  Zdd
Zej        aej         Z! G d de"          Z#dez  Z$e#fdZ% G d de"          Z& G d dej'                  Z(edk    r ej)                     dS dS )    N)OrderedDict)support)	SomeClassis_instance)uncache)NonCallableMockCallableMixinsentinel	MagicMockMockNonCallableMagicMockpatch_patchDEFAULTcall_get_targetbuiltinsz%s.PTModuleTc                 v      G  fddt                     }|s fd} fd}||_        ||_         |            S )Nc                       e Zd Z fdZdS )_get_proxy.<locals>.Proxyc                 $    t          |          S N)getattrselfnameobjs     7/usr/lib/python3.11/unittest/test/testmock/testpatch.py__getattr__z%_get_proxy.<locals>.Proxy.__getattr__   s    3%%%    N)__name__
__module____qualname__r   )r   s   r   Proxyr      s.        	& 	& 	& 	& 	& 	& 	&r    r$   c                 *    t          ||           d S r   )setattr)r   r   valuer   s      r   __setattr__z_get_proxy.<locals>.__setattr__    s    Cu%%%%%r    c                 (    t          |           d S r   )delattrr   s     r   __delattr__z_get_proxy.<locals>.__delattr__"   s    Cr    )objectr(   r+   )r   get_onlyr$   r(   r+   s   `    r   
_get_proxyr.      s    & & & & & & & & & &  (	& 	& 	& 	& 	&	 	 	 	 	''577Nr    c                   l    e Zd Zd Zd Zd ZdZed             Ze	d             Z
 G d de          Zd	S )
Fooc                     d S r    r   as     r   __init__zFoo.__init__/         r    c                     d S r   r2   r3   s     r   fzFoo.f0   r6   r    c                     d S r   r2   r   s    r   gzFoo.g1   r6   r    barc                      d S r   r2   r2   r    r   static_methodzFoo.static_method4   s    r    c                     d S r   r2   )clss    r   class_methodzFoo.class_method7   s    4r    c                       e Zd Zd ZdS )Foo.Barc                     d S r   r2   r:   s    r   r4   z	Foo.Bar.a;   r6   r    Nr!   r"   r#   r4   r2   r    r   BarrC   :   s        r    rF   N)r!   r"   r#   r5   r8   r;   foostaticmethodr>   classmethodrA   r,   rF   r2   r    r   r0   r0   .   s        
C \ [    f     r    r0   z%s.Fooc                     d S r   r2   r4   bs     r   functionrM   @   r6   r    c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )	Containerc                     i | _         d S r   valuesr:   s    r   r5   zContainer.__init__D   s    r    c                     | j         |         S r   rQ   r   r   s     r   __getitem__zContainer.__getitem__G   s    {4  r    c                     || j         |<   d S r   rQ   )r   r   r'   s      r   __setitem__zContainer.__setitem__J   s    !Dr    c                     | j         |= d S r   rQ   rT   s     r   __delitem__zContainer.__delitem__M   s    Kr    c                 *    t          | j                  S r   )iterrR   r:   s    r   __iter__zContainer.__iter__P   s    DK   r    N)r!   r"   r#   r5   rU   rW   rY   r\   r2   r    r   rO   rO   C   s_          ! ! !" " "  ! ! ! ! !r    rO   c                      e Zd ZdudZd Zd Zd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d  Z!d! Z"d" Z#d# Z$d$ Z%d% Z&d& Z'd' Z(d( Z)d) Z*d* Z+d+ Z,d, Z-d- Z.d. Z/d/ Z0d0 Z1d1 Z2d2 Z3d3 Z4d4 Z5d5 Z6d6 Z7d7 Z8d8 Z9d9 Z:d: Z;d; Z<d< Z=d= Z>d> Z?d? Z@d@ ZAdA ZBdB ZCdC ZDdD ZEdE ZFdF ZGdG ZHdH ZIdI ZJdJ ZKdK ZLdL ZMdM ZNdN ZOdO ZPdP ZQdQ ZRdR ZSdS ZTdT ZUdU ZVdV ZWdW ZXdX ZYdY ZZ e[dZd[          d\             Z\ e[dZd]          d^             Z]d_ Z^d` Z_da Z`db Zadc Zbdd Zcde Zddf Zedg Zfdh Zgdi Zhdj Zidk Zjdl Zkdm Zldn Zmdo Zndp Zodq Zpdr Zqds ZrdtS )v	PatchTestTc                     t           }|st          }|                     t          |           |                     t          ||                     |                     t          |t                               d S r   )r   r   assertRaises	TypeError
assertTruer   assertFalser	   )r   r   magic	MockClasss       r   assertNotCallablezPatchTest.assertNotCallableW   sj    (	 	('I)S)))C33444S-8899999r    c                       G d dt                     t          j         dt          j                   fd            } |                                  j        t          j        d           d S )Nc                       e Zd Zej        ZdS )4PatchTest.test_single_patchobject.<locals>.SomethingNr!   r"   r#   r
   Original	attributer2   r    r   	Somethingri   b            )IIIr    rm   rl   c                  T                          j        t          j        d           d S N	unpatchedassertEqualrl   r
   Patchedrm   r   s   r   testz/PatchTest.test_single_patchobject.<locals>.teste   s'    Y0(2BKPPPPPr    patch not restoredr,   r   r
   rt   rs   rl   rk   r   rv   rm   s   ` @r   test_single_patchobjectz!PatchTest.test_single_patchobjecta   s    	* 	* 	* 	* 	* 	* 	* 	* 
ih.>	?	?	Q 	Q 	Q 	Q 	Q 
@	?	Q 	,h.?-	/ 	/ 	/ 	/ 	/r    c                     d}|                      t          |          5  t          j        dd           d d d            d S # 1 swxY w Y   d S )Nz>'Something' must be the actual object to be patched, not a strrm   do_something)assertRaisesRegexra   r   r,   )r   msgs     r   &test_patchobject_with_string_as_targetz0PatchTest.test_patchobject_with_string_as_targetm   s    N##Is33 	6 	6Ln555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6s   AAAc                       G d dt                     t          j         dd            fd            } |                                  j        t          j        d           d S )Nc                       e Zd Zej        ZdS )7PatchTest.test_patchobject_with_none.<locals>.SomethingNrj   r2   r    r   rm   r   s   rn   r    rm   rl   c                  >                          j        d           d S rp   )assertIsNonerl   ru   s   r   rv   z2PatchTest.test_patchobject_with_none.<locals>.testv   s"    i1;?????r    rw   )r,   r   rs   rl   r
   rk   ry   s   ` @r   test_patchobject_with_nonez$PatchTest.test_patchobject_with_noner   s    	* 	* 	* 	* 	* 	* 	* 	* 
id	3	3	@ 	@ 	@ 	@ 	@ 
4	3	@ 	,h.?-	/ 	/ 	/ 	/ 	/r    c                      G d dt                     t          j         dt          j                  t          j         dt          j                   fd                        } |                                  j        t          j        d                                j        t          j	        d           d S )Nc                   *    e Zd Zej        Zej        ZdS )6PatchTest.test_multiple_patchobject.<locals>.SomethingNr!   r"   r#   r
   rk   rl   	Original2next_attributer2   r    r   rm   r               )I%/NNNr    rm   rl   r   c                                            j        t          j        d                                 j        t          j        d           d S rp   )rs   rl   r
   rt   r   Patched2ru   s   r   rv   z1PatchTest.test_multiple_patchobject.<locals>.test   sY     Y0(2B(* * *Y5x7H(* * * * *r    rw   )
r,   r   r
   rt   r   rs   rl   rk   r   r   ry   s   ` @r   test_multiple_patchobjectz#PatchTest.test_multiple_patchobject   s    	0 	0 	0 	0 	0 	0 	0 	0 
ih.>	?	?	i!183D	E	E	* 	* 	* 	* 	* 
F	E 
@	?	* 	,h.?-	/ 	/ 	/183E-	/ 	/ 	/ 	/ 	/r    c                     t           }t          dt          z  t          j                  d             }	 t          j        a  |             |                     t           t          j                   |a d S # |a w xY w)N%s.somethingc                      d S r   r2   r2   r    r   rv   z8PatchTest.test_object_lookup_is_quite_lazy.<locals>.test   s    Dr    )	somethingr   r!   r
   
Something2replacement_valuers   r   originalrv   s      r    test_object_lookup_is_quite_lazyz*PatchTest.test_object_lookup_is_quite_lazy   s~    	~((*=	>	>	 	 
?	>		! 2IDFFFY(BCCC IIII    s   ;A3 3A7c                     t          dt          z  t          j                   fd            } |                                  t
          j        t          j        d           t          dt          z  t          j                  t          dt          z  t          j                   fd                        }                     t
          j        t          j        d                                t
          j	        t          j        d            |                                  t
          j        t          j        d                                t
          j	        t          j        d           t                      }t          j        |_        t          dt          z  |           fd            } |              |                                  t          |d           d S )Nr   c                  ^                          t          j        t          j        d           d S rp   )rs   PTModuler   r
   r   r:   s   r   rv   z"PatchTest.test_patch.<locals>.test   s2    X/1D(* * * * *r    rw   z%s.something_elsec                                            t          j        t          j        d                                 t          j        t          j        d           d S rp   )rs   r   r   r
   r   something_elseSomethingElser:   s   r   rv   z"PatchTest.test_patch.<locals>.test   sY     X/1D(* * *X4h6L(* * * * *r    %s.openc                  f                          t          dd          t          j        d           d S )Nfilenamerzopen not patched)rs   openr
   Handler:   s   r   rv   z"PatchTest.test_patch.<locals>.test   s8    T*c22HO/1 1 1 1 1r    )r   r!   r
   r   rs   r   r   rm   r   r   r   r   return_valuebuiltin_stringassertNotEqualr   )r   rv   mocks   `  r   
test_patchzPatchTest.test_patch   s   	~((*=	>	>	* 	* 	* 	* 
?	>	* 	+X-?-	/ 	/ 	/ 
~((*=	>	>	"X-x/E	F	F	* 	* 	* 	* 
G	F 
?	>	* 	+X-?-	/ 	/ 	/0(2H-	/ 	/ 	/ 	+X-?-	/ 	/ 	/0(2H-	/ 	/ 	/ vv$O	y>)4	0	0	1 	1 	1 	1 
1	0	1 	D$(<=====r    c                      t          dt          z  t          j                   fd            } |                                  t
          j        j        d           d S )Nz%s.SomeClass.class_attributec                  h                          t          j        j        t          j        d           d S rp   )rs   r   r   class_attributer
   ClassAttributer:   s   r   rv   z2PatchTest.test_patch_class_attribute.<locals>.test   s<     X/?%4kC C C C Cr    rw   )r   r!   r
   r   r   r   r   r   r   rv   s   ` r   test_patch_class_attributez$PatchTest.test_patch_class_attribute   s    	-8&
( 
(	C 	C 	C 	C
( 
(	C 	(,<.	0 	0 	0 	0 	0r    c                      G d dt                     t          j         d           fd            } |             t          j         d          t          j         d           fd                        }d x |t          j        t          j                  \   |t          j        t          j                   d S )Nc                   *    e Zd Zej        Zej        ZdS ):PatchTest.test_patchobject_with_default_mock.<locals>.TestN)r!   r"   r#   r
   rk   r   r   
something2r2   r    r   Testr      s         )I!+JJJr    r   r   c                 x                         | j        d                               | t          d           d S )N"Mock not passed into test function.patch with two arguments did not create a mock)rs   r   assertIsInstancer   )r   r   r   s    r   rv   z:PatchTest.test_patchobject_with_default_mock.<locals>.test   sU    T4>AC C C!!$	LN N N N Nr    r   c                                         | t          j        d                                |t          j        d                                |j        d                                |j        d                               |t          d                               |t          d                               |d                               |d           ||fS )Nz0Patched function didn't receive initial argumentz/Patched function didn't receive second argumentr   z)Second Mock not passed into test functionr   zunexpected value for mock1)	rs   r
   this1this2r   r   r   r   r   )r   r   mock1mock2r   
outerMock1
outerMock2r   s       r   rv   z:PatchTest.test_patchobject_with_default_mock.<locals>.test   s    UHNOQ Q QUHNNP P PUDOAC C CUDNHJ J J!!%LN N N!!%LN N N 
E3OPPP
E3OPPP%<r    )r,   r   r
   r   r   )r   rv   r   r   r   s   ` @@@r   "test_patchobject_with_default_mockz,PatchTest.test_patchobject_with_default_mock   s   	, 	, 	, 	, 	,6 	, 	, 	, 
dK	(	(	N 	N 	N 	N 	N 
)	(	N 		dK	(	(	dL	)	)	  	  	  	  	  	  	  
*	) 
)	(	 & #'&
Z!%hnhn!E!E
J 	X^X^,,,,,r    c                 n     t          dt          z  t                     fd            } |             d S )N%s.SomeClassspecc                                          t          |                                t          t          j        t
                                                   t          d            d S )Nc                      t           j        S r   r   
not_wibbler2   r    r   <lambda>z>PatchTest.test_patch_with_spec.<locals>.test.<locals>.<lambda>  	    i6J r    rs   r   rb   r   wibbler   r`   AttributeErrorMockSomeClassr   s    r   rv   z,PatchTest.test_patch_with_spec.<locals>.test  X    Y666OOK	(8)DDEEEn.J.JKKKKKr    )r   r!   r   r   s   ` r   test_patch_with_speczPatchTest.test_patch_with_spec  sO    	~(y	9	9	9	L 	L 	L 	L 
:	9	L
 	r    c                 t     t          j        t          dt                     fd            } |             d S )Nr   r   c                                          t          j        |                                t	          t          j        j        t                                                   t          d            d S )Nc                  $    t           j        j        S r   r   r   r   r2   r    r   r   zDPatchTest.test_patchobject_with_spec.<locals>.test.<locals>.<lambda>      i&?&J r    	rs   r   r   rb   r   r   r   r`   r   MockAttributer   s    r   rv   z2PatchTest.test_patchobject_with_spec.<locals>.test  x    Y6FFFOOK	(A(H'02 2 3 3 3nJJL L L L Lr    r   r,   r   r   s   ` r   test_patchobject_with_specz$PatchTest.test_patchobject_with_spec  sP    	i!2	C	C	C	L 	L 	L 	L 
D	C	L 	r    c                 f     t          dt          z  dg           fd            } |             d S )Nr   r   r   c                                          t          |                                t          t          j        t
                                                   t          d            d S )Nc                      t           j        S r   r   r2   r    r   r   zFPatchTest.test_patch_with_spec_as_list.<locals>.test.<locals>.<lambda>  r   r    r   r   s    r   rv   z4PatchTest.test_patch_with_spec_as_list.<locals>.test  r   r    r   r!   r   s   ` r   test_patch_with_spec_as_listz&PatchTest.test_patch_with_spec_as_list  sQ    	~(z	:	:	:	L 	L 	L 	L 
;	:	L
 	r    c                 l     t          j        t          ddg           fd            } |             d S )Nr   r   r   c                                          t          j        |                                t	          t          j        j        t                                                   t          d            d S )Nc                  $    t           j        j        S r   r   r2   r    r   r   zLPatchTest.test_patchobject_with_spec_as_list.<locals>.test.<locals>.<lambda>*  r   r    r   r   s    r   rv   z:PatchTest.test_patchobject_with_spec_as_list.<locals>.test$  r   r    r   r   s   ` r   "test_patchobject_with_spec_as_listz,PatchTest.test_patchobject_with_spec_as_list#  sR    	i!2(	D	D	D	L 	L 	L 	L 
E	D	L 	r    c                      t          dt          z            t          dt          z  dg           fd                        } |             d S )Nr   r   r   r   c                                          t          |                                t          t          j        t
                                                   t          d            d S )Nc                      t           j        S r   r   r2   r    r   r   zMPatchTest.test_nested_patch_with_spec_as_list.<locals>.test.<locals>.<lambda>6  r   r    r   )r   MockOpenr   s     r   rv   z;PatchTest.test_nested_patch_with_spec_as_list.<locals>.test1  sZ     Y666OOK	(8)DDEEEn.J.JKKKKKr    )r   r   r!   r   s   ` r   #test_nested_patch_with_spec_as_listz-PatchTest.test_nested_patch_with_spec_as_list/  si    	y>)	*	*	~(z	:	:	:	L 	L 	L 	L 
;	: 
+	*	L 	r    c                 d     t          dt          z  d           fd            } |             d S )Nr   Tr   c                                           t                       j                             t           fd           d S )Nc                       j         S r   r   r   s   r   r   zIPatchTest.test_patch_with_spec_as_boolean.<locals>.test.<locals>.<lambda>A  
    m6N r    rs   r   r   r`   r   r   s   `r   rv   z7PatchTest.test_patch_with_spec_as_boolean.<locals>.test;  I    Y666  n.N.N.N.NOOOOOr    r   r   s   ` r   test_patch_with_spec_as_booleanz)PatchTest.test_patch_with_spec_as_boolean:  sO    	~(t	4	4	4	P 	P 	P 	P 
5	4	P 	r    c                 j     t          j        t          dd           fd            } |             d S )Nr   Tr   c                                           t                       j                             t           fd           d S )Nc                       j         S r   r   r   s   r   r   zPPatchTest.test_patch_object_with_spec_as_boolean.<locals>.test.<locals>.<lambda>M  r   r    r   r   s   `r   rv   z>PatchTest.test_patch_object_with_spec_as_boolean.<locals>.testG  r   r    )r   r,   r   r   s   ` r   &test_patch_object_with_spec_as_booleanz0PatchTest.test_patch_object_with_spec_as_booleanF  sN    	h$	7	7	7	P 	P 	P 	P 
8	7	P 	r    c                 d     t          dt          z  d           fd            } |             d S )Nr   Tr   c                                          t          | t                                |                                            j                             t          fd           d S )Nc                       j         S r   r   )instances   r   r   zVPatchTest.test_patch_class_acts_with_spec_is_inherited.<locals>.test.<locals>.<lambda>[  s
    h6I r    )rb   r   r   rf   r   r`   r   )r   r   r   s    @r   rv   zDPatchTest.test_patch_class_acts_with_spec_is_inherited.<locals>.testS  sl    OOKyAABBB$}H""8,,,OOn.I.I.I.IJJJJJr    r   r   s   ` r   ,test_patch_class_acts_with_spec_is_inheritedz6PatchTest.test_patch_class_acts_with_spec_is_inheritedR  sO    	~(t	4	4	4	K 	K 	K 	K 
5	4	K 	r    c                      t          dt          z  t          j        d           fd            } |                                  t
          d            d S )N
%s.froobleTcreatec                  R                          t          t          j                   d S r   )rs   froobler
   Froobler:   s   r   rv   zLPatchTest.test_patch_with_create_mocks_non_existent_attributes.<locals>.testa  s"    Wh&677777r    c                      t           S r   r  r2   r    r   r   zPPatchTest.test_patch_with_create_mocks_non_existent_attributes.<locals>.<lambda>f      W r    )r   r   r
   r  r`   	NameErrorr   s   ` r   4test_patch_with_create_mocks_non_existent_attributesz>PatchTest.test_patch_with_create_mocks_non_existent_attributes`  sj    	|n,h.>t	L	L	L	8 	8 	8 	8 
M	L	8 	)__55555r    c                      t          j        t          dt          j        d           fd            } |                                  t          t          d                     d S )Nr  Tr   c                  \                          t          j        t          j                   d S r   )rs   r   r  r
   r  r:   s   r   rv   zRPatchTest.test_patchobject_with_create_mocks_non_existent_attributes.<locals>.testj  s%    Y.0@AAAAAr    )r   r,   r   r
   r  rc   hasattrr   s   ` r   :test_patchobject_with_create_mocks_non_existent_attributeszDPatchTest.test_patchobject_with_create_mocks_non_existent_attributesi  st    	iH,<T	J	J	J	B 	B 	B 	B 
K	J	B 	I6677777r    c                    |                      t                    5  t          dt          z  t          j                  d             } |             d d d            n# 1 swxY w Y   |                      t          d            d S )Nr   c                      d S r   r2   r2   r    r   rv   z9PatchTest.test_patch_wont_create_by_default.<locals>.testt      r    c                      t           S r   r  r2   r    r   r   z=PatchTest.test_patch_wont_create_by_default.<locals>.<lambda>x  r  r    )r`   r   r   r   r
   r  r  r   s     r   !test_patch_wont_create_by_defaultz+PatchTest.test_patch_wont_create_by_defaultr  s    ~.. 	 	<.0(2BCC DCDFFF		 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 	)__55555s   6AA!$A!c                 *   |                      t                    5  t          j        t          dt
          j                  d             } |             d d d            n# 1 swxY w Y   |                     t          t          d                     d S )Nordc                      d S r   r2   r2   r    r   rv   z?PatchTest.test_patchobject_wont_create_by_default.<locals>.test}  r  r    )	r`   r   r   r,   r   r
   r  rc   r  r   s     r   'test_patchobject_wont_create_by_defaultz1PatchTest.test_patchobject_wont_create_by_default{  s    ~.. 	 	\)UH,<== >=DFFF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	E2233333s   9A  A$'A$c                     t          t          dz             d             }t          t          dz             d             }|                      |            d           |                      |            d           d S )Nz.ordc                 .    d| _         t          d          S )Ne   c)r   r  )mock_ords    r   test_ordz>PatchTest.test_patch_builtins_without_create.<locals>.test_ord  s    $'H!s88Or    z.openc                     | j         }d|j        _         t          d          }|                                }|                                 |S )Nabcdzdoesnotexists.txt)r   readr   close)	mock_openmfobjdatas       r   	test_openz?PatchTest.test_patch_builtins_without_create.<locals>.test_open  sA    &A"(AF+,,D99;;DJJLLLKr    r  r  r   r!   rs   )r   r  r$  s      r   "test_patch_builtins_without_createz,PatchTest.test_patch_builtins_without_create  s    	x			 	 
 		 
x	 	 	 	 
!	 	 	S)))f-----r    c                      G d dt                     t          j         dt          d                      fd            } |                                                                  t
          j                   d S )Nc                   $    e Zd Zed             ZdS )5PatchTest.test_patch_with_static_methods.<locals>.Fooc                      t           j        S r   )r
   Staticr2   r    r   wootz:PatchTest.test_patch_with_static_methods.<locals>.Foo.woot  s
    &r    N)r!   r"   r#   rH   r,  r2   r    r   r0   r)    s-        ' ' \' ' 'r    r0   r,  c                      t           j        S r   )r
   rt   r2   r    r   r   z:PatchTest.test_patch_with_static_methods.<locals>.<lambda>  s	    8H r    c                  l                                                          t          j                   d S r   )rs   r,  r
   rt   )r0   r   s   r   	anonymousz;PatchTest.test_patch_with_static_methods.<locals>.anonymous  s*    SXXZZ)9:::::r    )r,   r   rH   rs   r,  r
   r+  )r   r/  r0   s   ` @r   test_patch_with_static_methodsz(PatchTest.test_patch_with_static_methods  s    	' 	' 	' 	' 	'& 	' 	' 	'
 
c6<0H0H#I#I	J	J	; 	; 	; 	; 	; 
K	J	;	X_55555r    c                      t           j        }t          j        t           dd           fd            } |                                  t           j        |           d S )Nr0   c                  H                          t          j        d           d S Nr0   )rs   r
   r0   r:   s   r   r/  z-PatchTest.test_patch_local.<locals>.anonymous  s!    X\511111r    )r
   r0   r   r,   rs   )r   rG   r/  s   `  r   test_patch_localzPatchTest.test_patch_local  se    l	hu	-	-	2 	2 	2 	2 
.	-	2	s+++++r    c                      G d dt                     } |            t          j        _        t          j         dd           fd            } |                                  j        t          j                   d S )Nc                       e Zd ZdZdS )'PatchTest.test_patch_slots.<locals>.Foo)r0   N)r!   r"   r#   	__slots__r2   r    r   r0   r7    s         IIIr    r0   c                  >                          j        d           d S r3  )rs   r0   rG   r   s   r   r/  z-PatchTest.test_patch_slots.<locals>.anonymous  s!    SWe,,,,,r    )r,   r
   r0   r   rs   )r   r0   r/  rG   s   `  @r   test_patch_slotszPatchTest.test_patch_slots  s    	! 	! 	! 	! 	!& 	! 	! 	! cee,	c5%	(	(	- 	- 	- 	- 	- 
)	(	-	(,/////r    c                 ^     G d dt                      G  fddt                     } t          j         dt          j                  |          } |            }|                                 |                                                      j        t          j        d           d S )Nc                       e Zd Zej        ZdS )=PatchTest.test_patchobject_class_decorator.<locals>.SomethingNrj   r2   r    r   rm   r>    rn   r    rm   c                   (    e Zd Z fdZ fdZdS )7PatchTest.test_patchobject_class_decorator.<locals>.Fooc                 T                         j        t          j        d           d S rp   rr   
other_selfrm   r   s    r   test_methodzCPatchTest.test_patchobject_class_decorator.<locals>.Foo.test_method  s2      !4h6F!,. . . . .r    c                 T                         j        t          j        d           d S Nznon-test method patched)rs   rl   r
   rk   rB  s    r   not_test_methodzGPatchTest.test_patchobject_class_decorator.<locals>.Foo.not_test_method  s2      !4h6G!:< < < < <r    N)r!   r"   r#   rD  rG  ru   s   r   r0   r@    sQ        . . . . . .< < < < < < < <r    r0   rl   rw   )	r,   r   r
   rt   rD  rG  rs   rl   rk   )r   r0   r8   rm   s   `  @r    test_patchobject_class_decoratorz*PatchTest.test_patchobject_class_decorator  s    	* 	* 	* 	* 	* 	* 	* 	*	< 	< 	< 	< 	< 	< 	< 	<& 	< 	< 	< Eel9k83CDDSIICEE		,h.?-	/ 	/ 	/ 	/ 	/r    c                      G d dt                     } G  fddt                     } t          dt          z            |          } |            }|                                 |                                                      |j        t          j        d                                t          j
        t          j        d           d S )Nc                       e Zd Zej        ZdS )7PatchTest.test_patch_class_decorator.<locals>.SomethingNrj   r2   r    r   rm   rK    rn   r    rm   c                   (    e Zd ZdZ fdZ fdZdS )1PatchTest.test_patch_class_decorator.<locals>.Foowhateverc                 J                         t          j        |d           d S rp   )rs   r   r   )rC  mock_somethingr   s     r   rD  z=PatchTest.test_patch_class_decorator.<locals>.Foo.test_method  s/      !3^!,. . . . .r    c                 ^                         t          j        t          j        d           d S rF  )rs   r   r   r
   rm   )rC  r   s    r   rG  zAPatchTest.test_patch_class_decorator.<locals>.Foo.not_test_method  s2      !3X5G!:< < < < <r    N)r!   r"   r#   test_class_attrrD  rG  r:   s   r   r0   rM    sL        (O. . . . .< < < < < < <r    r0   r   rw   )r,   r   r!   rD  rG  rs   rl   r
   rk   r   r   rm   )r   rm   r0   r8   s   `   r   test_patch_class_decoratorz$PatchTest.test_patch_class_decorator  s    	* 	* 	* 	* 	* 	* 	* 	*		< 		< 		< 		< 		< 		< 		<& 		< 		< 		< /eNX-..s33CEE		,h.?-	/ 	/ 	/+X-?-	/ 	/ 	/ 	/ 	/r    c                 4     G d dt                     t          j         dt          j                  t          j         dt          j                   fd                        } |                                  j        t          j        d           d S )Nc                   *    e Zd Zej        Zej        ZdS )3PatchTest.test_patchobject_twice.<locals>.SomethingNr   r2   r    r   rm   rV    r   r    rm   rl   c                  T                          j        t          j        d           d S rp   rr   ru   s   r   rv   z.PatchTest.test_patchobject_twice.<locals>.test  s)     Y0(2BKPPPPPr    rw   rx   ry   s   ` @r   test_patchobject_twicez PatchTest.test_patchobject_twice  s    	0 	0 	0 	0 	0 	0 	0 	0 
ih.>	?	?	ih.>	?	?	Q 	Q 	Q 	Q 	Q 
@	? 
@	?	Q 	,h.?-	/ 	/ 	/ 	/ 	/r    c                     t                      dd                                }t          j                  fd            } |                                  |           t          j        ddi           fd            } |                                  |           t          j        dg           fd            } |                                  |           d S )	Nr   initialotherc                  "    d d<    d= d d<   d S N   r4   r[  something elser\  r2   rG   s   r   rv   z'PatchTest.test_patch_dict.<locals>.test       CHI+CLLLr    r4   rL   c                                           t                     d                                 d         d           d S Nr_  r4   rL   rs   lenr:  s   r   rv   z'PatchTest.test_patch_dict.<locals>.test  ?    SXXq)))SXs+++++r    rK   c                                           t                     d                                 d         d           d S rd  re  r:  s   r   rv   z'PatchTest.test_patch_dict.<locals>.test  rg  r    r,   copyr   dictrs   r   r   rv   rG   s   `  @r   test_patch_dictzPatchTest.test_patch_dict  s,    (([9988::	C	, 	, 	, 	, 
	,
 	h'''	C#s	$	$	, 	, 	, 	, 	, 
%	$	, 	h'''	C*	&	&	, 	, 	, 	, 	, 
'	&	, 	h'''''r    c                     t                      t                      d<   dd<   j                                        }t	          j                  fd            } |                                  j        |           t	          j        ddi           fd            } |                                  j        |           d S )Nr[  r   r\  c                  "    d d<    d= d d<   d S r^  r2   ra  s   r   rv   z=PatchTest.test_patch_dict_with_container_object.<locals>.test&  rb  r    r4   rL   c                                           t           j                  d                                 d         d           d S rd  )rs   rf  rR   r:  s   r   rv   z=PatchTest.test_patch_dict_with_container_object.<locals>.test0  sA    S__a000SXs+++++r    rO   r,   rR   rj  r   rk  rs   rl  s   `  @r   %test_patch_dict_with_container_objectz/PatchTest.test_patch_dict_with_container_object  s    kkI#G:??$$	C	, 	, 	, 	, 
	,
 	X...	C#s	$	$	, 	, 	, 	, 	, 
%	$	, 	X.....r    c                     t                      dd                                }t          j        d           fd            } |                                  |           t          j        ddid           fd            } |                                  |           t          j        d	gd           fd
            } |                                  |           d S )Nr   rZ  Tclearc                  H                          i            d d<   d d<   d S Nr_  r4   r`  r\  rs   r:  s   r   rv   z2PatchTest.test_patch_dict_with_clear.<locals>.test>  s/    S"%%%CH+CLLLr    r4   rL   c                  8                          ddi           d S Nr4   rL   rx  r:  s   r   rv   z2PatchTest.test_patch_dict_with_clear.<locals>.testH  #    S3*-----r    rK   c                  8                          ddi           d S rz  rx  r:  s   r   rv   z2PatchTest.test_patch_dict_with_clear.<locals>.testP  r{  r    ri  rl  s   `  @r   test_patch_dict_with_clearz$PatchTest.test_patch_dict_with_clear:  sC    (([9988::	Ct	$	$	$	, 	, 	, 	, 	, 
%	$	,
 	h'''	C#s4	0	0	0	. 	. 	. 	. 	. 
1	0	. 	h'''	C*T	2	2	2	. 	. 	. 	. 	. 
3	2	. 	h'''''r    c                     t                      t                      d<   dd<   j                                        }t	          j        d           fd            } |                                  j        |           t	          j        ddid           fd	            } |                                  j        |           d S )
Nr[  r   r\  Trt  c                  R                          j        i            d d<   d d<   d S rw  rs   rR   r:  s   r   rv   zGPatchTest.test_patch_dict_with_container_object_and_clear.<locals>.test`  s1    SZ,,,CH+CLLLr    r4   rL   c                  B                          j        ddi           d S rz  r  r:  s   r   rv   zGPatchTest.test_patch_dict_with_container_object_and_clear.<locals>.testj  s%    SZ#s44444r    rq  rl  s   `  @r   /test_patch_dict_with_container_object_and_clearz9PatchTest.test_patch_dict_with_container_object_and_clearY  s    kkI#G:??$$	Ct	$	$	$	, 	, 	, 	, 	, 
%	$	,
 	X...	C#s4	0	0	0	5 	5 	5 	5 	5 
1	0	5 	X.....r    c                     ddi}t          j        |d          5 }|                     |ddi           d d d            n# 1 swxY w Y   |                     |ddi           d S )Nr4   rL   r  )r4   )r   rk  rs   )r   rG   patcheds      r   "test_patch_dict_as_context_managerz,PatchTest.test_patch_dict_as_context_managers  s    CjZs### 	2wWsCj111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2sCj)))))s   A  AAc                 ~   i }t          dt          z  t                                t          dt          z  t                      d          t          j        t          t                                t          j        |          d                                                 }|                     |j        d           d S )Nr   Tautospecc                      d S r   r2   r2   r    r   	some_namez0PatchTest.test_name_preserved.<locals>.some_name}  s	     r    r  )r   r!   r,   r   rk  rs   )r   rG   r  s      r   test_name_preservedzPatchTest.test_name_preservedz  s    	~(&((	3	3	~(&((T	B	B	B	i	*	*	C 
 
+	* 
C	B 
4	3 	+[99999r    c                     i }t          j        |ddi          d             }|                     t                    5   |             d d d            n# 1 swxY w Y   |                     |i            d S )Nr4   rL   c                       t          d          )NKonradr  r2   r    r   rv   z1PatchTest.test_patch_with_exception.<locals>.test  s    H%%%r    )r   rk  r`   r  rs   )r   rG   rv   s      r   test_patch_with_exceptionz#PatchTest.test_patch_with_exception  s    	C#s	$	$	& 	& 
%	$	& y)) 	 	DFFF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	b!!!!!s   AAAc                 `     t          j        dddi           fd            } |             d S )Nz
os.environkonrad_delongz
some valuec                  H                          dt          j                   d S )Nr  )assertInosenvironr:   s   r   rv   z3PatchTest.test_patch_dict_with_string.<locals>.test  s    MM/2:66666r    )r   rk  r   s   ` r   test_patch_dict_with_stringz%PatchTest.test_patch_dict_with_string  sJ    	L?L"A	B	B	7 	7 	7 	7 
C	B	7 	r    c                 8    t           j                                        }t          j        dddi           fd            }	 ddit           _         |                                  t           j        ddi           |t           _        d S # |t           _        w xY w)Nz%unittest.test.testmock.support.targetr<   BARc                  N                          t          j        ddd           d S )NBAZr  rG   r<   )rs   r   targetr:   s   r   rv   z<PatchTest.test_patch_dict_decorator_resolution.<locals>.test  s)    W^U5-I-IJJJJJr    rG   r  )r   r  rj  r   rk  rs   r   s   `  r   $test_patch_dict_decorator_resolutionz.PatchTest.test_patch_dict_decorator_resolution  s     >&&((	;eU^	L	L	K 	K 	K 	K 
M	L	K	&#U^GNDFFFW^eU^<<<%GNNNXGN%%%%s   :B Bc                    t          dt          z  t          d          d             }|                     t          |           t          j        t          dt          d          d             }|                     t          |           t          dt          z  d          d             }|                     t          |           t          j        t          dd          d	             }|                     t          |           d S )
Nr   Tr   spec_setc                     d| _         d S NrG   zre   s    r   rv   z+PatchTest.test_patch_spec_set.<locals>.test      IKKKr    r   c                     d| _         d S r  r  r  s    r   rv   z+PatchTest.test_patch_spec_set.<locals>.test  r  r    r  c                     d| _         d S r  r  r  s    r   rv   z+PatchTest.test_patch_spec_set.<locals>.test  r  r    c                     d| _         d S r  r  r  s    r   rv   z+PatchTest.test_patch_spec_set.<locals>.test  r  r    )r   r!   r   r`   r   r,   r   r   s     r   test_patch_spec_setzPatchTest.test_patch_spec_set  s   	~(y4	H	H	H	  	  
I	H	  	.$///	g{T	J	J	J	  	  
K	J	  	.$///	~(4	8	8	8	  	  
9	8	  	.$///	g{T	:	:	:	  	  
;	:	  	.$/////r    c                     t          dt          z  d          d             }|                     t          |           d S )Nr   Tr  c                 (     |             }d|_         d S r  r  )re   r   s     r   rv   z-PatchTest.test_spec_set_inherit.<locals>.test  s     y{{HHJJJr    )r   r!   r`   r   r   s     r   test_spec_set_inheritzPatchTest.test_spec_set_inherit  sL    	~(4	8	8	8	 	 
9	8	 	.$/////r    c                    t           }t          dt          z            }|                     t           |           |                                }	 |                     ||           |                     t           |           |                                 n# |                                 w xY w|                     t           |           d S )Nr   )r   r   r!   assertIsstartassertIsNotstop)r   r   patcherr   s       r   test_patch_start_stopzPatchTest.test_patch_start_stop  s    122i***}}	T8,,,MM)T***LLNNNNGLLNNNNi*****s   1B B+c                     t          t          dd          }|                     |                                           d S Nr<   r_  )r   foo_namer   r  r   r  s     r   test_stop_without_startz!PatchTest.test_stop_without_start  s5    %++',,..)))))r    c                     t          t          dd          }|                                 |                                 |                     |                                           d S r  )r   r  r  r  r   r  s     r   test_stop_idempotentzPatchTest.test_stop_idempotent  sO    %++',,..)))))r    c                    t           }t          j        t          dd          }|                     t           |           |                                }	 |                     |d           |                     t           |           |                                 n# |                                 w xY w|                     t           |           d S )Nr   rG   )r   r   r,   r   r  r  rs   r  )r   r   r  replaceds       r   test_patchobject_start_stopz%PatchTest.test_patchobject_start_stop  s    ,xe<<i***==??	Xu---MM)X...LLNNNNGLLNNNNi*****s   1B B/c                 t   ddi}|                                 }t          j        |dgd          }|                     ||           |                                 	 |                     |ddi           |                                 n# |                                 w xY w|                     ||           d S )NrG   r<   spameggsTrt  r  r  )rj  r   rk  rs   r  r  r   dr   r  s       r   test_patch_dict_start_stopz$PatchTest.test_patch_dict_start_stop  s    EN6688*Q!1 2$???H%%%	Q 0111LLNNNNGLLNNNNH%%%%%s   B	 	Bc                     ddi}|                                 }t          j        |dgd          }|                     |                                           |                     ||           d S )NrG   r<   r  Trt  )rj  r   rk  rc   r  rs   r  s       r   "test_patch_dict_stop_without_startz,PatchTest.test_patch_dict_stop_without_start  sj    EN6688*Q!1 2$???(((H%%%%%r    c                 R   | ddi                                 } G fddt                    } t          j        ddid          |          }|                     |            |            }|                                 |                     |           |                                 |                     |            |            }|                                 |                     |           |                                 |                     |           d S )	Nr  r  c                   (    e Zd Z fdZ fdZdS )7PatchTest.test_patch_dict_class_decorator.<locals>.Testc                 8                         ddi           d S NrG   r<   rx  r   r  thiss    r   
test_firstzBPatchTest.test_patch_dict_class_decorator.<locals>.Test.test_first  #      UEN33333r    c                 8                         ddi           d S r  rx  r  s    r   test_secondzCPatchTest.test_patch_dict_class_decorator.<locals>.Test.test_second  r  r    N)r!   r"   r#   r  r  )r  r  s   r   r   r    sQ        4 4 4 4 4 44 4 4 4 4 4 4 4r    r   rG   r<   Trt  )rj  r,   r   rk  rs   r  r  )r   r   r   rv   r  r  s       @@r   test_patch_dict_class_decoratorz)PatchTest.test_patch_dict_class_decorator  sM   V6688	4 	4 	4 	4 	4 	4 	4 	46 	4 	4 	4 9uz!eU^4888>>H%%%tvvH%%%H%%%tvvH%%%H%%%%%r    c                      G d dt                     } G d d          }|| |            |fD ]}t          |          t          j         dd           fd            } |                                  j        d                                |j        d                                dj                   d S )Nc                       e Zd ZdZdS )0PatchTest.test_get_only_proxy.<locals>.SomethingrG   Nr!   r"   r#   rG   r2   r    r   rm   r  -          CCCr    rm   c                       e Zd ZdZdS )4PatchTest.test_get_only_proxy.<locals>.SomethingElserG   Nr  r2   r    r   r   r  /  r  r    r   rG   r<   c                  >                          j        d           d S Nr<   rs   rG   proxyr   s   r   rv   z+PatchTest.test_get_only_proxy.<locals>.test5  !      E22222r    r,   r.   r   rs   rG   assertNotIn__dict__r   rm   r   thingrv   r  s   `    @r   test_get_only_proxyzPatchTest.test_get_only_proxy,  s   	 	 	 	 	 	 	 		 	 	 	 	 	 	 	 yy{{MI 		4 		4Eu%%E\%..3 3 3 3 3 /.3DFFFUY...UY...UEN3333		4 		4r    c                      G d dt                     } G d d          }|| |            |fD ]}t          |d          t          j         dd           fd	            } |                                  j        d                                |j        d                                dj                   d S )
Nc                       e Zd ZdZdS )6PatchTest.test_get_set_delete_proxy.<locals>.SomethingrG   Nr  r2   r    r   rm   r  ?  r  r    rm   c                       e Zd ZdZdS ):PatchTest.test_get_set_delete_proxy.<locals>.SomethingElserG   Nr  r2   r    r   r   r  A  r  r    r   F)r-   rG   r<   c                  >                          j        d           d S r  r  r  s   r   rv   z1PatchTest.test_get_set_delete_proxy.<locals>.testG  r  r    r  r  s   `    @r   test_get_set_delete_proxyz#PatchTest.test_get_set_delete_proxy>  s   	 	 	 	 	 	 	 		 	 	 	 	 	 	 	 yy{{MI 		4 		4Ey5999E\%..3 3 3 3 3 /.3DFFFUY...UY...UEN3333		4 		4r    c                 x   t           dt                      d}t          t          fi |}|                                }|                                 |                     t           |           |                     |j        	                                d           | 
                    |j        t                     d S )N!   side_effectzfoo.bar.return_valuerG   )KeyErrorr   r   r  r  r  r`   rs   rG   r<   r   r   kwargsr  r   s       r   test_patch_keyword_argsz!PatchTest.test_patch_keyword_argsP  s    !)2"& & ++F++}}(D))),,,dh	22222r    c                    t           dt                      d}t          j        t          dfi |}|                                }|                                 |                     t           |           |                     |j	        
                                d           |                     |j	        t                     d S )Nr  r  r8   )r  r   r   r,   r0   r  r  r`   rs   rG   r<   r   r  s       r   test_patch_object_keyword_argsz(PatchTest.test_patch_object_keyword_args]  s    !)2"& & ,sC22622}}(D))),,,dh	22222r    c                 d   ddi}|                                 }t          j        |ddd          }|                                 	 |                     |t          ddd                     |                                 n# |                                 w xY w|                     ||           d S )NrG   r<   r_        )rG   r<   baz)rj  r   rk  r  rs   r  )r   r   rj  r  s       r   test_patch_dict_keyword_argsz&PatchTest.test_patch_dict_keyword_argsj  s    5>}}*X1!;;;	Xtqa'@'@'@AAALLNNNNGLLNNNN4(((((s   &B Bc                      G d dt                     } fd fd fd} t          t          d          |          } |            }                     t          |            |             t
          j        t                   } t          j         |dd          |          } |            }                     t          |            |             d S )	Nc                   @    e Zd Zd Zd Zd ZdZ G d de          ZdS )$PatchTest.test_autospec.<locals>.Booc                     d S r   r2   r3   s     r   r5   z-PatchTest.test_autospec.<locals>.Boo.__init__{  r6   r    c                     d S r   r2   r3   s     r   r8   z&PatchTest.test_autospec.<locals>.Boo.f|  r6   r    c                     d S r   r2   r:   s    r   r;   z&PatchTest.test_autospec.<locals>.Boo.g}  r6   r    r<   c                       e Zd Zd ZdS )(PatchTest.test_autospec.<locals>.Boo.Barc                     d S r   r2   r:   s    r   r4   z*PatchTest.test_autospec.<locals>.Boo.Bar.a  r6   r    NrE   r2   r    r   rF   r    s        !!!!!r    rF   N)	r!   r"   r#   r5   r8   r;   rG   r,   rF   r2   r    r   Boor  z  s^        '''   C" " " " "f " " " " "r    r  c                 ~     | d           |                      d                               t          |            d S N   )assert_called_withr`   ra   r   r   s    r   _testz&PatchTest.test_autospec.<locals>._test  s@    DGGG##A&&&i.....r    c                    |                      d           | j                             d                               t          | j                    |                                  | j                                                             t          | j        d                               t
          t          | d           | j                                         | j        j                                                             t
          t          | j        d           | 	                                 | j	                                         | j	        
                                 | j	        j
                                                             t          | j	        j
        d           | 	                                
                                 | 	                                j
                                                             t          | 	                                j
        d                               t
          t          | j	        d                               t
          t          | 	                                d           d S )Nr  hr<   rL   )r8   r  r`   ra   r;   r   r   rG   lowerrF   r4   r  s    r   _test2z'PatchTest.test_autospec.<locals>._test2  s   FF1IIIF%%a(((i000FFHHHF%%'''i333ngtSAAAHNNHN--///ngtxGGGHHJJJH'')))HJJLLLHJ))+++iQ777HHJJLLNNNHHJJL++---iq999ngtxEEEngtxxzz3GGGGGr    c                      |             |              | d                                          | t                     | S r
  )r  r0   )r   r  r  r   s    r   rM   z)PatchTest.test_autospec.<locals>.function  sK    E$KKKF4LLLF4477OOOMM$$$$Kr    Tr  r0   )r,   r   r  r  r0   sysmodulesr!   )r   r  rM   rv   r   moduler  r  s   `     @@r   test_autospeczPatchTest.test_autospecy  s/   	" 	" 	" 	" 	"& 	" 	" 	"	/ 	/ 	/ 	/ 	/
	H 	H 	H 	H 	H:	 	 	 	 	 	 	 .uX---h77tvvd###X&9u|FED999(CCtvvd###r    c                 d     t          dt          z  d           fd            } |             d S )N%s.functionTr  c                    t                                                                t          t           j                                       t          t           j                   t          d                               t          t           j                   t                               d           t                                            t                                            t          dd           t                               dd                               t          t                                          t          t          t           d           d S )Nr     r_  rG   )
rM   assert_not_calledr`   AssertionErrorassert_calledassert_called_oncer  ra   r   r   r  s    r   rv   z.PatchTest.test_autospec_function.<locals>.test  s    &&(((nh.DEEEnh.IJJJQKKKnh.HIII''***""$$$'')))QNNN''1---i222ngxGGGGGr    r   r   s   ` r   test_autospec_functionz PatchTest.test_autospec_function  sO    	}x'$	7	7	7	H 	H 	H 	H 
8	7	H 	r    c                     t          dt          z  dd          d             } |            }|                     |d           d S )Nr  Tr_  )r  r   c                 "    t          dd          S )Nr  r  )rM   )mock_functions    r   rv   z.PatchTest.test_autospec_keywords.<locals>.test  s     Aq>>!r    r%  )r   rv   results      r   test_autospec_keywordsz PatchTest.test_autospec_keywords  sb    	}x'$
 
 
	" 	"
 
	" #####r    c                     t          dt          z  d          5 }t                                           |                                 d d d            d S # 1 swxY w Y   d S )Nz%s.Foo.static_methodTr  )r   r!   r0   r>   assert_called_once_withr   methods     r   test_autospec_staticmethodz$PatchTest.test_autospec_staticmethod  s    )H4tDDD 	-**,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-   .AAAc                     t          dt          z  d          5 }t                                           |                                 d d d            d S # 1 swxY w Y   d S )Nz%s.Foo.class_methodTr  )r   r!   r0   rA   r'  r(  s     r   test_autospec_classmethodz#PatchTest.test_autospec_classmethod  s    (83dCCC 	-v**,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-r+  c           	      z    G d d          }|                     ddd           t          j        |dd	          5 } |ddd           |                     t          |           |                     t          |d           |                     t          |dddd
           d d d            d S # 1 swxY w Y   d S )Nc                   &    e Zd Zedd            ZdS );PatchTest.test_autospec_staticmethod_signature.<locals>.Foo
   c                    d S r   r2   )r4   rL   r  s      r   r>   zIPatchTest.test_autospec_staticmethod_signature.<locals>.Foo.static_method  s    .2dr    Nr1  )r!   r"   r#   rH   r>   r2   r    r   r0   r0    s&        222 \222r    r0   r  r  r_  r  r>   Tr  r  )r>   r   r,   r`   ra   r   r0   r)  s      r   $test_autospec_staticmethod_signaturez.PatchTest.test_autospec_staticmethod_signature  s%   	3 	3 	3 	3 	3 	3 	3 	3 	!Q!$$$\#>>> 	?&F1a1i000i333iAqA>>>		? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?   A&B00B47B4c           	      z    G d d          }|                     ddd           t          j        |dd	          5 } |ddd           |                     t          |           |                     t          |d           |                     t          |dddd
           d d d            d S # 1 swxY w Y   d S )Nc                   &    e Zd Zedd            ZdS ):PatchTest.test_autospec_classmethod_signature.<locals>.Foor1  c                    d S r   r2   )r@   r4   rL   r  s       r   rA   zGPatchTest.test_autospec_classmethod_signature.<locals>.Foo.class_method  s    26$r    Nr3  )r!   r"   r#   rI   rA   r2   r    r   r0   r:    s&        666 [666r    r0   r  r  r_  r4  rA   Tr  r  )rA   r   r,   r`   ra   r5  s      r   #test_autospec_classmethod_signaturez-PatchTest.test_autospec_classmethod_signature  s%   	7 	7 	7 	7 	7 	7 	7 	7 	A###\#~=== 	?F1a1i000i333iAqA>>>		? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?r7  c                    t          dt          z  dd          }|                     t          |j                   t
          j        t                   }t          j        |ddd          }|                     t          |j                   d S )Nr  r_  T)newr  rM   )r   r!   r`   ra   r  r  r  r,   )r   r  r  s      r   test_autospec_with_newz PatchTest.test_autospec_with_new  su    0a$GGG)W]333X&,vzq4HHH)W]33333r    c                 H    G d dt                     }t          t          |          }|                                }	 |                     ||           |                     |j        t                     |                                 d S # |                                 w xY w)Nc                       e Zd Zg ZdS )0PatchTest.test_autospec_with_object.<locals>.BarN)r!   r"   r#   extrar2   r    r   rF   rB    s        EEEr    rF   r  )r0   r   r  r  r   rC  listr  )r   rF   r  r   s       r   test_autospec_with_objectz#PatchTest.test_autospec_with_object  s    	 	 	 	 	# 	 	 	 3///}}	!!$,,,!!$*d333LLNNNNNGLLNNNNs   6B B!c                 .   t           }t          t          d          }|                                }	 |                     ||           |                      |d          |           |                                 d S # |                                 w xY w)NTr  r_  )r0   r   r  r  r   r  )r   FooClassr  r   s       r   test_autospec_inheritsz PatchTest.test_autospec_inherits  s    4000}}	!!$111!!$$q''8444LLNNNNNGLLNNNNs   5A> >Bc                    t          t          d          }|                                }	 |                     dt	          |                     |                     dt	          |j                             |                     dt	           |d                                |                     dt	           |d           j                             |                                 d S # |                                 w xY w)NTr  z name='Foo'z name='Foo.f'z name='Foo()'z name='Foo().f')r   r  r  r  reprr8   r  )r   r  r   s      r   test_autospec_namezPatchTest.test_autospec_name&  s    4000}}	MM-d444MM/4<<888MM/4T

+;+;<<<MM+T$$t**,-?-?@@@LLNNNNNGLLNNNNs   B(C* *D c                 6   t          j        t          dt                                d             }	  |             n#  t          j                    }Y nxY wt          j        d d d          }|                    ||           }|                     d|           d S )Nr8   c                      t           r   )r  r2   r    r   rv   z'PatchTest.test_tracebacks.<locals>.test4  s      r    r   zraise AssertionError)	r   r,   r0   r  exc_infounittestTextTestResult_exc_info_to_stringr  )r   rv   errr$  	tracebacks        r   test_tracebackszPatchTest.test_tracebacks3  s    	c3	)	)	! 	! 
*	)	!	!DFFFF	!,..CCC(tQ77..sD99	,i88888s	   
= Ac                 @   t          t          t                    }|                                }|                                 |                                }|                                 |                     ||           ||fD ]}|                     |           d S )Nnew_callable)r   r  r   r  r  r  rf   r   r  m1m2r   s        r   test_new_callable_patchz!PatchTest.test_new_callable_patchA  s    /CDDD]]__]]__R   F 	' 	'D""2&&&&	' 	'r    c                 L   t          j        t          dt                    }|                                }|                                 |                                }|                                 |                     ||           ||fD ]}|                     |           d S )Nr8   rV  )r   r,   r0   r   r  r  r  rf   rX  s        r   test_new_callable_patch_objectz(PatchTest.test_new_callable_patch_objectN  s    ,sC6JKKK]]__]]__R   F 	' 	'D""2&&&&	' 	'r    c                     G fddt                     t          t          dd          }|                                }	 |                     t          |                     |                     j        t          dd                     |	                                 d S # |	                                 w xY w)Nc                       e Zd ZdZ fdZdS ):PatchTest.test_new_callable_keyword_arguments.<locals>.BarNc                     |_         d S r   r  r   r  rF   s     r   r5   zCPatchTest.test_new_callable_keyword_arguments.<locals>.Bar.__init__^      #


r    r!   r"   r#   r  r5   rF   s   r   rF   r`  \  3        F$ $ $ $ $ $ $r    rF   r  r  )rW  arg1arg2)rh  ri  )
r,   r   r  r  r  typers   r  rk  r  )r   r  r!  rF   s      @r   #test_new_callable_keyword_argumentsz-PatchTest.test_new_callable_keyword_arguments[  s    	$ 	$ 	$ 	$ 	$ 	$ 	$& 	$ 	$ 	$
 sCCCMMOO	MM$q''3'''SZ11)=)=)=>>>LLNNNNNGLLNNNNs   AB' 'B=c                 <    G fddt                     t          t                    }|                                 	 |                     j        t                               |                                 n# |                                 w xY wt          t                    }|                                 	 |                     j        t                               |                                 d S # |                                 w xY w)Nc                       e Zd ZdZ fdZdS )-PatchTest.test_new_callable_spec.<locals>.BarNc                     |_         d S r   rb  rc  s     r   r5   z6PatchTest.test_new_callable_spec.<locals>.Bar.__init__m  rd  r    re  rf  s   r   rF   rn  k  rg  r    rF   rW  r   r   )rW  r  r  )r,   r   r  r  rs   r  rk  r  )r   r  rF   s     @r   test_new_callable_specz PatchTest.test_new_callable_specj  s   	$ 	$ 	$ 	$ 	$ 	$ 	$& 	$ 	$ 	$
 s===	SZ3888LLNNNNGLLNNNNsSAAA	SZs);););<<<LLNNNNNGLLNNNNs   )B B)D Dc                 f   dt           z  }t          |t                    }|                     t          |j                   t          |t          d          }|                                }	 |                     |d           |                                 d S # |                                 w xY w)Nz	%s.weeeeerV  T)rW  r   F)rd   )r  r   r   r`   r   r  rf   r  )r   non_existent_attrpr!  s       r   test_new_callable_createz"PatchTest.test_new_callable_create  s    '(2#/BBB.!'222#/  GGII	""1E"222FFHHHHHAFFHHHHs   -B B0c                     |                      t          t          t          t	                      t
                     |                      t          t          j        t          dt	                      t
                     d S )N)r>  rW  r8   )r`   
ValueErrorr   r  r,   r   r0   r:   s    r   'test_new_callable_incompatible_with_newz1PatchTest.test_new_callable_incompatible_with_new  sk    xVXXI 	 	
 	
 	
 	c3FHH" 	 	
 	
 	
 	
 	
r    c                     |                      t          t          t          t          d           |                      t          t          j        t          dt          d           d S )NT)rW  r  r8   )r`   rw  r   r  r   r,   r0   r:   s    r   ,test_new_callable_incompatible_with_autospecz6PatchTest.test_new_callable_incompatible_with_autospec  sd    xi 	 	
 	
 	
 	c3Y 	 	
 	
 	
 	
 	
r    c                 |    G d dt                     }t          t          t          t           |f}|D ]}dD ]}|di}t	          t
          fd|i|}|                                }	 |j        }|                     t          t          |d           |                                 m# |                                 w xY wd S )Nc                       e Zd ZdS )>PatchTest.test_new_callable_inherit_for_mocks.<locals>.MockSubNr!   r"   r#   r2   r    r   MockSubr}            Dr    r  r  TrW  x)r   r   r   r   r   r  r  r   r`   r   r   r  )	r   r  MockClassesKlassargr  rt  r!  r   s	            r   #test_new_callable_inherit_for_mocksz-PatchTest.test_new_callable_inherit_for_mocks  s    	 	 	 	 	d 	 	 	 19dG
 ! 		 		E)  t(AAA&AAGGII ~H%%ngxMMMFFHHHHAFFHHHH		 		s   $)B""B8c                     G d dt                     }t          t          |d          }|                                }	 |                     t          ||                     |                     t          t          |d           |	                                 n# |	                                 w xY w| 
                    |j        t                     d S )Nc                       e Zd Zd ZdS )>PatchTest.test_new_callable_inherit_non_mock.<locals>.NotAMockc                     || _         d S r   r   )r   r   s     r   r5   zGPatchTest.test_new_callable_inherit_non_mock.<locals>.NotAMock.__init__  s     			r    N)r!   r"   r#   r5   r2   r    r   NotAMockr    s#        ! ! ! ! !r    r  Trp  r   )r,   r   r  r  rb   r   r`   r   r   r  rs   r   r0   )r   r  rt  r!  s       r   "test_new_callable_inherit_non_mockz,PatchTest.test_new_callable_inherit_non_mock  s    	! 	! 	! 	! 	!v 	! 	! 	! (===GGII	OOK844555ngq.IIIFFHHHHAFFHHHH%%%%%s    AB B0c                 6   | t            G fddt                    } t          t          t                    |          } |                                              |                                             |                     t                      d S )Nc                   (    e Zd Z fdZd Zd ZdS )>PatchTest.test_new_callable_class_decorating.<locals>.SomeTestc                                          t                                         t          |                               t          t                     d S r   )r  r0   r  r   r   )r   mock_foor   rv   s     r   r  zDPatchTest.test_new_callable_class_decorating.<locals>.SomeTest._test  sI      h///c8,,,%%c955555r    c                 0    |                      |           d S r   r  r   r  s     r   test_twozGPatchTest.test_new_callable_class_decorating.<locals>.SomeTest.test_two      

8$$$$$r    c                 0    |                      |           d S r   r  r  s     r   test_onezGPatchTest.test_new_callable_class_decorating.<locals>.SomeTest.test_one  r  r    Nr!   r"   r#   r  r  r  )r   rv   s   r   SomeTestr    sQ        6 6 6 6 6 6
% % %% % % % %r    r  rV  )r0   r,   r   r  r   r  r  r  )r   r  r   rv   s     @@r   "test_new_callable_class_decoratingz,PatchTest.test_new_callable_class_decorating  s    
	% 
	% 
	% 
	% 
	% 
	% 
	% 
	%v 
	% 
	% 
	% ;5	:::8DD



c8$$$$$r    c                     t           t           j        }t           j        }t          j        t
          dd          }t          j        t           dd          }||fD ]}|                                 	                      t                                           t           j        d                                t           j        d           |	                                 n# |	                                 w xY w                     t                                           t           j        |                                t           j        |           t          j        t
          dd           fd            } |             d S )Nr  r  )r8   r;   r_  r  c                                           t                                          t          j        d                               t          j        d           d S )Nr_  r  )r  r0   rs   r8   r;   )original_foor   s   r   rv   z+PatchTest.test_patch_multiple.<locals>.test  sM    MM#|,,,SUA&&&SUA&&&&&r    )
r0   r8   r;   r   multipler  r  r  rs   r  )r   
original_f
original_gpatcher1patcher2r  rv   r  s   `      @r   test_patch_multiplezPatchTest.test_patch_multiple  sb   U
U
>(a1555>#a000) 	0 	0GMMOOOc<000  ***  ***MM#|,,,SUJ///SUJ//// 
A	+	+	+	' 	' 	' 	' 	' 
,	+	'
 	s   5AC%%C;c                     |                      t          t          j        t                     |                      t          t          j        t
                     d S r   )r`   rw  r   r  r  r0   r:   s    r   test_patch_multiple_no_kwargsz'PatchTest.test_patch_multiple_no_kwargs  s<    *enh???*enc:::::r    c                 B    t           t           j        }t           j        }t          j        t
          t          dt                     fd            } |                                  t           j        |                                t           j        |           d S )Nr_  r8   r;   rG   c                                         t                                          t          j        |                                t          j        d                                t          j        |                               t          | t                                                   t          |t                               d S Nr_  	r  r0   r8   rs   r;   rG   rb   r   r   )r8   rG   r  r   s     r   rv   z8PatchTest.test_patch_multiple_create_mocks.<locals>.test  s    MM#|,,,MM#%###SUA&&&MM#'3'''OOK955666OOKY7788888r    r0   r8   r;   r   r  r  r   rs   )r   r  r  rv   r  s   `   @r    test_patch_multiple_create_mocksz*PatchTest.test_patch_multiple_create_mocks  s    U
U
	Gqg	>	>	>	9 	9 	9 	9 	9 
?	>	9 	
+++
+++++r    c                     t           j        }t           j        }t          j        t           dd          }d|_        t          j        t           dt                    }d|_        |g|_        | fd            } |                                  t           j        |                                t           j        |           d S )Nr8   r_  r;   c                                          t          j        |                                t          j        d           d S r  )r  r0   r;   rs   r8   )r;   r   s    r   rv   zHPatchTest.test_patch_multiple_create_mocks_different_order.<locals>.test  s7    MM#%###SUA&&&&&r    )	r0   r8   r;   r   r,   attribute_namer   additional_patchersrs   )r   r  r  r  r\  rv   s   `     r   0test_patch_multiple_create_mocks_different_orderz:PatchTest.test_patch_multiple_create_mocks_different_order  s    U
U
,sC++!$S#w//"',g#		' 	' 	' 	' 
	' 	
+++
+++++r    c                     t           t           j        }t           j        }t          j        t
          t                    t          j        t
          t                    t          t
          dz             fd                                    }t          j        t
          t                    t          t
          dz             t          j        t
          t                    fd                                    }t          t
          dz             t          j        t
          t                    t          j        t
          t                    fd                                    } fd |              |              |                                  t           j        |                                t           j        |           d S )N)r8   ra  z.gc                      | fi | d S r   r2   r;   r  r  s     r   test1z?PatchTest.test_patch_multiple_stacked_decorators.<locals>.test1+  #     E!vr    c                      | fi | d S r   r2   r  s     r   test2z?PatchTest.test_patch_multiple_stacked_decorators.<locals>.test21  r  r    c                      | fi | d S r   r2   r  s     r   test3z?PatchTest.test_patch_multiple_stacked_decorators.<locals>.test37  r  r    c                 l   |                     d          }|                     d          }                    |                               t                                         t          j        |                               t          j        |                                t          j        |                               t          |t                                                   t          | t                                                   t          |t                               d S )Nr8   rG   )
poprc   r  r0   r8   r;   rG   rb   r   r   )r;   r  r8   rG   r  r   s       r   r  z?PatchTest.test_patch_multiple_stacked_decorators.<locals>._test=  s    

3A**U##CV$$$MM#|,,,MM#%###MM#%###MM#'3'''OOK955666OOK955666OOKY7788888r    r  )r   r  r  r  r  r  r  r  s   `     @@r   &test_patch_multiple_stacked_decoratorsz0PatchTest.test_patch_multiple_stacked_decorators&  s   U
U
	G	,	,	,	g	.	.	.	x$			 	 	 	 
 	 
/	. 
-	,	 
G	,	,	,	x$			g	.	.	.	 	 	 	 
/	. 
 	 
-	,	 
x$			G	,	,	,	g	.	.	.	 	 	 	 
/	. 
-	, 
 			9 	9 	9 	9 	9 	9 	
+++
+++++r    c                 r   t           }t           j        }t           j        }t          j        t
          t          dt                    }|                                }	 |d         }|d         }|                     t          |          t          ddg                     | 
                    t           |           | 
                    t           j        |           | 
                    t           j        |           |                     t          |t                               |                     t          |t                               |                                 n# |                                 w xY w|                     t           j        |           |                     t           j        |           d S )Nr_  r  r8   rG   )r0   r8   r;   r   r  r  r   r  rs   setr  rG   rb   r   r   r  )r   r  r  r  r  r$  r8   rG   s           r   (test_patch_multiple_create_mocks_patcherz2PatchTest.test_patch_multiple_create_mocks_patcherQ  sH   U
U
.WwGGG	sA-CS[[#sEl*;*;<<<MM#|,,,MM#%###MM#'3'''OOK955666OOKY77888LLNNNNGLLNNNN
+++
+++++s   C-E E4c                    | t           t           j        }t           j        } G fddt                    } t	          j        t          t          dt                    |          } |            }|                                 |	                                 | 
                    t           j        |           | 
                    t           j        |           d S )Nc                   (    e Zd Z fdZd Zd ZdS )@PatchTest.test_patch_multiple_decorating_class.<locals>.SomeTestc                                         t                                          t          j        |                               t          j        d                                t          j        |                               t          |t                                                   t          |t                               d S r  r  )r   r8   rG   r  rv   s      r   r  zFPatchTest.test_patch_multiple_decorating_class.<locals>.SomeTest._testr  s    c<000ceQ'''  ***cgs+++Ay 9 9:::C ; ;<<<<<r    c                 2    |                      ||           d S r   r  r   r8   rG   s      r   r  zIPatchTest.test_patch_multiple_decorating_class.<locals>.SomeTest.test_twoz      

1c"""""r    c                 2    |                      ||           d S r   r  r  s      r   r  zIPatchTest.test_patch_multiple_decorating_class.<locals>.SomeTest.test_one|  r  r    Nr  )r  rv   s   r   r  r  p  sQ        = = = = = =# # ## # # # #r    r  r_  r  )r0   r8   r;   r,   r   r  r  r   r  r  rs   )r   r  r  r  r  r  rv   s        @@r   $test_patch_multiple_decorating_classz.PatchTest.test_patch_multiple_decorating_classj  s    U
U
	# 	# 	# 	# 	# 	# 	# 	#v 	# 	# 	#
5>1'
 
 

  


+++
+++++r    c                    t          j        t          d          }|                     t          |j                   t          j        t          dd          }|                                 	 |                     t          j        d           |                                 n# |                                 w xY w| 	                    t          t          d                     d S )Nblam)r  T)r  r   )r   r  r0   r`   r   r  rs   r  r  rc   r  r  s     r   test_patch_multiple_createz$PatchTest.test_patch_multiple_create  s    .6222.'-888.6$???	SXv...LLNNNNGLLNNNNf--.....s   - B" "B8c                    t          j        t          t          ddg          }|                                }	 |                     t          j        |d                    t          j                            d           t          j                            d           t          j        j        	                    d           t          j        j        	                    d           | 
                    t          t          t          j        dd            |                                 d S # |                                 w xY w)Nr4   rL   )rG   r  rG   r  r  r  )r   r  r0   r   r  rs   rG   r4   rL   r  r`   r   r&   r  )r   r  r$  s      r   test_patch_multiple_spec_setz&PatchTest.test_patch_multiple_spec_set  s     .'S#JGGG	SWfUm444GIIaLLLGIIaLLLGI((+++GI((+++ngswTJJJLLNNNNNGLLNNNNs   CD( (D>c                 j    G d dt                     }t          j        t          t          t          |          }|                                }	 |                     t          j        |d                    |                     t          j        |d                    | 	                    t          j        |           | 	                    t          j        |           | 
                    t          j        t          j                   |                                 d S # |                                 w xY w)Nc                       e Zd ZdS )9PatchTest.test_patch_multiple_new_callable.<locals>.ThingNr~  r2   r    r   Thingr    r  r    r  )r8   r;   rW  r8   r;   )r,   r   r  r0   r   r  r  r8   r;   r   r  r  )r   r  r  r$  s       r    test_patch_multiple_new_callablez*PatchTest.test_patch_multiple_new_callable  s   	 	 	 	 	F 	 	 	 .7gE
 
 
 	MM#%---MM#%---!!#%///!!#%///SUCE***LLNNNNNGLLNNNNs   B6D D2c                 `   t           j        }t           j        }t          j        t           dd          t          j        t           dd          t          j        t           dd          d                                     }t          j        t           dd          t          j        t           dd          t          j        t           dd          d                                     }t          j        t           dd          t          j        t           dd          t          j        t           dd          d                                     }|||fD ]]}|                     t          |           |                     t           j        |           |                     t           j        |           ^d S )Nr;   r  missingr8   c                      d S r   r2   r2   r    r   thing1z3PatchTest.test_nested_patch_failure.<locals>.thing1  	     dr    c                      d S r   r2   r2   r    r   thing2z3PatchTest.test_nested_patch_failure.<locals>.thing2  r  r    c                      d S r   r2   r2   r    r   thing3z3PatchTest.test_nested_patch_failure.<locals>.thing3  r  r    )r0   r8   r;   r   r,   r`   r   rs   )r   r  r  r  r  r  funcs          r   test_nested_patch_failurez#PatchTest.test_nested_patch_failure  s{   U
U
	c3	"	"	c9a	(	(	c3	"	" 
#	" 
)	( 
#	" 		c9a	(	(	c3	"	"	c3	"	" 
#	" 
#	" 
)	( 		c3	"	"	c3	"	"	c9a	(	( 
)	( 
#	" 
#	" 	FF* 	0 	0Dnd333SUJ///SUJ////	0 	0r    c                    t           j        }t           j        }t           j        }d }t	          j        t           dd          t	          j        t           d|          t	          j        t           dd          d                                     }t	          j        t           d|          t	          j        t           dd          t	          j        t           dd          d                                     }t	          j        t           dd          t	          j        t           dd          t	          j        t           d|          d	                                     }|||fD ]}}|                     t          |           |                     t           j        |           |                     t           j        |           |                     t           j        |           ~d S )
Nc                       t          d          Ncrasherr  r2   r    r   r  z4PatchTest.test_new_callable_failure.<locals>.crasher      I&&&r    r;   r  rG   rV  r8   c                      d S r   r2   r2   r    r   r  z3PatchTest.test_new_callable_failure.<locals>.thing1  r  r    c                      d S r   r2   r2   r    r   r  z3PatchTest.test_new_callable_failure.<locals>.thing2  r  r    c                      d S r   r2   r2   r    r   r  z3PatchTest.test_new_callable_failure.<locals>.thing3  r  r    )	r0   r8   r;   rG   r   r,   r`   r  rs   )	r   r  r  r  r  r  r  r  r  s	            r   test_new_callable_failurez#PatchTest.test_new_callable_failure  s   U
U
w	' 	' 	' 
c3	"	"	c5w	7	7	7	c3	"	" 
#	" 
8	7 
#	" 		c5w	7	7	7	c3	"	"	c3	"	" 
#	" 
#	" 
8	7 		c3	"	"	c3	"	"	c5w	7	7	7 
8	7 
#	" 
#	" 	FF* 	4 	4Di...SUJ///SUJ///SWl3333		4 	4r    c                    t           j        }t           j        }t          j        t           dd          }d|_        t          j        t           dd          }d|_        t          j        t           dd          }d|_        ||g||gfD ]o}||_        |d             }|                     t          |           | 	                    t           j        |           | 	                    t           j        |           pd S )Nr8   r  r;   r  c                      d S r   r2   r2   r    r   r  z3PatchTest.test_patch_multiple_failure.<locals>.func  r  r    )
r0   r8   r;   r   r,   r  r  r`   r   rs   )r   r  r  r  goodbadadditionalsr  s           r   test_patch_multiple_failurez%PatchTest.test_patch_multiple_failure  s    U
U
,sC++!$|Ca((!l3	1--& #;d3 	0 	0K*5G' Wnd333SUJ///SUJ////	0 	0r    c                 R   t           j        }t           j        }t           j        }d }t	          j        t           dd          }d|_        t	          j        t           dd          }d|_        t	          j        t           d|          }d|_        ||g||gfD ]}||_        |d             }	|                     t          |	           | 
                    t           j        |           | 
                    t           j        |           | 
                    t           j        |           d S )Nc                       t          d          r  r  r2   r    r   r  zCPatchTest.test_patch_multiple_new_callable_failure.<locals>.crasher  r  r    r8   r  r;   rG   rV  c                      d S r   r2   r2   r    r   r  z@PatchTest.test_patch_multiple_new_callable_failure.<locals>.func  r  r    )r0   r8   r;   rG   r   r,   r  r  r`   r  rs   )
r   r  r  r  r  r  r  r  r  r  s
             r   (test_patch_multiple_new_callable_failurez2PatchTest.test_patch_multiple_new_callable_failure
  s   U
U
w	' 	' 	' ,sC++!$|Ca((!l3G<<<" #;d3 		4 		4K*5G' Wi...SUJ///SUJ///SWl3333		4 		4r    c                      t          dt          fddi          } |            t          j        d           fd            } |                                  j        d           d S )Nr0   fishtastynearly gone)r  c                  >                          j        d           d S )Nr  )rs   r  r:  s   r   rv   z=PatchTest.test_patch_multiple_string_subclasses.<locals>.test*  s!    SX}55555r    )rj  strr   r  rs   r  )r   r0   rv   rG   s   `  @r   %test_patch_multiple_string_subclassesz/PatchTest.test_patch_multiple_string_subclasses'  s    53&67"344cee	-	0	0	0	6 	6 	6 	6 	6 
1	0	6 	7+++++r    zunittest.mock.patch.TEST_PREFIXrG   c                     G d dt                     } t          j         |dd          |          } |            }|                     |                                d           |                     |                                d           |                     |                                d           |                     |                                d           d S )Nc                   *    e Zd ZdZd Zd Zd Zd ZdS )-PatchTest.test_patch_test_prefix.<locals>.Foor   c                     | j         S r   r  r:   s    r   foo_onez5PatchTest.test_patch_test_prefix.<locals>.Foo.foo_one7  
    z!r    c                     | j         S r   r  r:   s    r   foo_twoz5PatchTest.test_patch_test_prefix.<locals>.Foo.foo_two9  r  r    c                     | j         S r   r  r:   s    r   r  z6PatchTest.test_patch_test_prefix.<locals>.Foo.test_one;  r  r    c                     | j         S r   r  r:   s    r   r  z6PatchTest.test_patch_test_prefix.<locals>.Foo.test_two=  r  r    N)r!   r"   r#   r  r  r  r  r  r2   r    r   r0   r  4  sU        E" " "" " "" " "" " " " "r    r0   r  changedr   )r,   r   rs   r  r  r  r  )r   r0   rG   s      r   test_patch_test_prefixz PatchTest.test_patch_test_prefix2  s    
	" 
	" 
	" 
	" 
	"& 
	" 
	" 
	" 4el333C88cee	222	22244444444r    r<   c                     G fddt                     }ddi t          j        d          |          } |            }|                     |                                ddi           |                     |                                ddi           |                     |                                ddi           |                     |                                ddi           d S )Nc                   8    e Zd Z fdZ fdZ fdZ fdZdS )2PatchTest.test_patch_dict_test_prefix.<locals>.Fooc                 "    t                    S r   rk  r   the_dicts    r   bar_onez:PatchTest.test_patch_dict_test_prefix.<locals>.Foo.bar_oneL      H~~%r    c                 "    t                    S r   r
  r  s    r   bar_twoz:PatchTest.test_patch_dict_test_prefix.<locals>.Foo.bar_twoN  r  r    c                 "    t                    S r   r
  r  s    r   r  z;PatchTest.test_patch_dict_test_prefix.<locals>.Foo.test_oneP  r  r    c                 "    t                    S r   r
  r  s    r   r  z;PatchTest.test_patch_dict_test_prefix.<locals>.Foo.test_twoR  r  r    N)r!   r"   r#   r  r  r  r  )r  s   r   r0   r  K  sy        & & & & && & & & && & & & && & & & & & &r    r0   keyr   r  )r  )r,   r   rk  rs   r  r  r  r  )r   r0   rG   r  s      @r   test_patch_dict_test_prefixz%PatchTest.test_patch_dict_test_prefixI  s    	& 	& 	& 	& 	& 	& 	&& 	& 	& 	& :&1ejy111#66SUU	(:;;;	(:;;;%)<===%)<=====r    c                    dD ]}t          dt          z  fi |di}|                                }	 |                     dt	          |                     |                     dt	          |j                             |                     dt	           |                                 |                     dt	           |            j                             |                                 # |                                 w xY wd S )Nr   r  r  r   Tz name='SomeClass'z! name='SomeClass.class_attribute'z name='SomeClass()'z# name='SomeClass().class_attribute')r   r!   r  r  rJ  r   r  )r   r  rt  r!  s       r   test_patch_with_spec_mock_reprz(PatchTest.test_patch_with_spec_mock_repr_  s    3 	 	Cnx/??C;??A		A1477;;;A"1#4557 7 73T!!##YY???C"1133#6779 9 9 	 	s   B&C--Dc                 \   t          dd          5 }|                     dt          |j                                                             |                     dt          |                                                                                     d d d            d S # 1 swxY w Y   d S )Nunittest.test.testmock.supportTr  z" name='support.SomeClass.wibble()'z$ name='support.SomeClass().wibble()')r   r  rJ  r   r   )r   r!  s     r   test_patch_nested_autospec_reprz)PatchTest.test_patch_nested_autospec_reprn  s    3dCCC 	8qMM>q{1133446 6 6MM@q{{}}3355668 8 8	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8s   BB!!B%(B%c                 :   dD ]}t          dt          z  fi |di}|                                }	 |                                 t	          j                    g}|                     |j        |           |                     |j        |           |                     |j        j        t	                      g            |            }|                    t	                                 |                     |j        |           |                                 |                    t	                                                                 |                     |j        |           |                     |j        t	          j                    g           |                     |j        j        t	                      g           |                     |j        t	          j                    g           |	                                 # |	                                 w xY wd S )Nr  r   T)
r   r!   r  r   r   rs   
mock_callsmethod_callsappendr  )r   r  rt  r!  kallsr$  s         r   test_mock_calls_with_patchz$PatchTest.test_mock_calls_with_patchw  s   3 	 	Cnx/??C;??A		A


  u555  777  !4tvvh???TVV$$$  u555TVV]]__---  u555  !2T[]]ODDD  !9DFF8DDD  !4t{}}oFFF/	 	s   F:HHc                    t          d          }|                     t          |j                   t	          d          5  t                      }|t          j        d<   d|_        t          d          }d|_        |                                 |	                                 d d d            n# 1 swxY w Y   | 
                    |j        d           d S )Nsquizz.squozzsquizz   r_  )r   r`   ImportErrorr  r   r   r  r  squozzr  rs   )r   p1r#  s      r   test_patch_imports_lazilyz#PatchTest.test_patch_imports_lazily  s    ?##+rx000X 	 	VVF$*CK!FM''BFMHHJJJGGIII	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	*****s   A#B..B25B2c                     G d d           G fddt                     fd} |d          d             }t          d          5  t                      }|t          j        d<   |                     t          |           d d d            n# 1 swxY w Y   |                     j        d	         t                     | 	                    j        d
         d           | 	                    j        d         d           d S )Nc                       e Zd ZdZdS );PatchTest.test_patch_propagates_exc_on_exit.<locals>.holderNNNN)r!   r"   r#   rN  r2   r    r   holderr+    s        'HHHr    r-  c                        e Zd Zd fd	ZeZdS )APatchTest.test_patch_propagates_exc_on_exit.<locals>.custom_patchNc                 J    t          j        | |||           |||f_        d S r   )r   __exit__rN  )r   etypevaltbr-  s       r   r1  zJPatchTest.test_patch_propagates_exc_on_exit.<locals>.custom_patch.__exit__  s*    eS"555"'b.r    r,  )r!   r"   r#   r1  r  )r-  s   r   custom_patchr/    s4        1 1 1 1 1 1 DDDr    r5  c                 X    t          |           \  }} ||t          d dd d d i 	  	        S )NF)r   r   )r  getterrl   r5  s      r   with_custom_patchzFPatchTest.test_patch_propagates_exc_on_exit.<locals>.with_custom_patch  s=     +F 3 3FI<	7D%dB  r    r"  c                     t           r   )RuntimeErrorr   s    r   rv   z9PatchTest.test_patch_propagates_exc_on_exit.<locals>.test  s    r    r#  r   r  zexception value not propagatedr  z"exception traceback not propagated)
r   r   r   r  r  r`   r:  r  rN  assertIsNotNone)r   r8  rv   r#  r5  r-  s       @@r   !test_patch_propagates_exc_on_exitz+PatchTest.test_patch_propagates_exc_on_exit  s   	( 	( 	( 	( 	( 	( 	( 	(	 	 	 	 	 	 	6 	 	 		 	 	 	 	 
	?	+	+	 	 
,	+	 X 	2 	2VVF$*CK!lD111		2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	foa(,777V_Q/<	> 	> 	>V_Q/@	B 	B 	B 	B 	Bs   9BBBc                 6   dD ]}t          dt          z  fddi|di}|                     t          |j                   |                     t
          d            t          t          fddi|di}|                                 |                                 d S )Nr   r  r  z%s.doesnotexistr   Tc                      t           S r   )doesnotexistr2   r    r   r   z1PatchTest.test_create_and_specs.<locals>.<lambda>  s     r    )r   r!   r`   ra   r  r  MODNAMEr  )r   kwargrt  s      r   test_create_and_specszPatchTest.test_create_and_specs  s    5 		 		E'(2 ' '4 '' 'Ai111i)=)=>>> g<<d<udm<<AGGIIIFFHHHH		 		r    c                    t           }dD ]S}t          t          fddi|di}|                     t          |j                   |                     t           |           TdD ]S}t          t          fddi|di}|                     t          |j                   |                     t           |           TdD ]S}t          t          fddi|di}|                     t          |j                   |                     t           |           Td S )Nr  r  r   r   r  r  )r  r  r   )r   r   rB  r`   ra   r  r  )r   r   rC  rt  s       r   test_multiple_specszPatchTest.test_multiple_specs  s%   ) 	. 	.Eg888eQZ88Ai111MM(H----) 	. 	.Eg888eQZ88Ai111MM(H----- 	. 	.Eg44A4%44Ai111MM(H----	. 	.r    c                     t          t          ddd          }|                                }	 |j         d|_        |                                 d S # |                                 w xY w)NFr?  r_  )r   rB  r  does_not_existr  )r   rt  r   s      r    test_specs_false_instead_of_nonez*PatchTest.test_specs_false_instead_of_none  s^    'FFFwwyy	"#DFFHHHHHAFFHHHHs   A A(c                     dD ]z}t          t          fi |di}|                                }	 |                     t          t
          |d           |                                 b# |                                 w xY wd S )Nr  r   doesnotexit)r   rB  r  r`   r   r   r  r   rC  rt  r!  s       r   test_falsey_speczPatchTest.test_falsey_spec  s    5 	 	Eg,,%,,A		A!!.'1mLLL	 	s   "A%%A;c                 J   dD ]}t          t          fddi|di}|                                }	 |                     t          t
          |dd           |                     t          t          |d           |                                 # |                                 w xY wd S )NrF  r  TrA  r   )r   rB  r  r`   r   r&   r   r  rM  s       r   test_spec_set_truezPatchTest.test_spec_set_true  s    ) 	 	Eg>>>>>A		A!!.'1"0+? ? ?!!.'1nMMM	 	s   AB

B c                     d}t          t          |          }|                                }	 |                     t	          |                     |                                 d S # |                                 w xY w)N)__call__r   )r   rB  r  rb   callabler  r   r   rt  r!  s       r   test_callable_spec_as_listz$PatchTest.test_callable_spec_as_list  sf    '%%%GGII	OOHQKK(((FFHHHHHAFFHHHH   "A& &A<c                     d}t          t          |          }|                                }	 |                     t	          |                     |                                 d S # |                                 w xY w)Nr  r   )r   rB  r  rc   rS  r  rT  s       r   test_not_callable_spec_as_listz(PatchTest.test_not_callable_spec_as_list  sh    '%%%GGII	Xa[[)))FFHHHHHAFFHHHHrV  c                 |    t           j        t           j        t           j        }t	          dt
                                                     t	          dt                                                     t	          d           fd            } |                                  t           j        |           d S )N	os.unlinkos.chdirzos.pathc                     t          j                                         t          j        |                                t          j                                       t          j                   d S r   )r   stopallr  r  pathunlinkchdir)	mock_pathr`  r   r_  s    r   r  z-PatchTest.test_patch_stopall.<locals>.patched  sV    MOOOMM"'9---MM")V,,,MM"(E*****r    )	r  r_  r`  r^  r   r   r  r   r  )r   r^  r  r`  r_  s   `  @@r   test_patch_stopallzPatchTest.test_patch_stopall  s    wk9%%++---j.))//111	y			+ 	+ 	+ 	+ 	+ 	+ 
		+ 				bgt$$$$$r    c                     g  G d dt                     fdfddD              t          j                     |                     g d           d S )Nc                       e Zd ZdxZxZZdS )*PatchTest.test_stopall_lifo.<locals>.thingN)r!   r"   r#   onetwothreer2   r    r   r  re  *  s         $$C$#r    r  c                 b      G  fddt                      fd d d dd d d i 	  	        S )Nc                   &     e Zd Z fdZ xZS )?PatchTest.test_stopall_lifo.<locals>.get_patch.<locals>.mypatchc                 r                                    t          |                                           S r   )r  superr  )r   	__class__rl   mypatchstoppeds    r   r  zDPatchTest.test_stopall_lifo.<locals>.get_patch.<locals>.mypatch.stop/  s1    NN9--- $//44666r    )r!   r"   r#   r  __classcell__)rn  rl   ro  rp  s   @r   ro  rk  .  sH        7 7 7 7 7 7 7 7 7 7 7 7r    ro  c                       S r   r2   r  s   r   r   z@PatchTest.test_stopall_lifo.<locals>.get_patch.<locals>.<lambda>2  s    5 r    F)r   )rl   ro  rp  r  s   `@r   	get_patchz.PatchTest.test_stopall_lifo.<locals>.get_patch-  sr    7 7 7 7 7 7 7 7 7& 7 7 7 7====)T4 $dB8 8 8r    c                 J    g | ]} |                                            S r2   )r  ).0r3  rs  s     r   
<listcomp>z/PatchTest.test_stopall_lifo.<locals>.<listcomp>4  s-    CCCC3				CCCr    )rf  rg  rh  )rh  rg  rf  )r,   r   r]  rs   )r   rs  rp  r  s    @@@r   test_stopall_lifozPatchTest.test_stopall_lifo(  s    	% 	% 	% 	% 	%F 	% 	% 	%	8 	8 	8 	8 	8 	8 	DCCC+BCCCC"9"9"9:::::r    c                    i }ddi}ddd|                                 }|                                 }                                 }t          j        |ddd                                           t          j        |dd	i                                           t          j                  fd
            } |             |                     ||           |                     ||           |                     |           t          j                     |                     ||           |                     ||           |                     |           d S )Nr  r4   ABr  r  IIIr  rL   c                       d= d S r
  r2   )dic3s   r   r  z2PatchTest.test_patch_dict_stopall.<locals>.patchedC  s    Qr    )rj  r   rk  r  r   rs   r]  )r   dic1dic2origdic1origdic2origdic3r  r  s          @r   test_patch_dict_stopallz!PatchTest.test_patch_dict_stopall9  s]   3x399;;99;;99;;
4ST**++11333
4!S""((***	D			 	 	 	 
		 				D(+++D(+++x(((x(((x(((x(((((r    c                    t           j        }t           j        }i }ddd}|                                }|                                }t	          dt
                                                     t	          dt                                                     t	          j        |ddd                                           t	          j        |                                           |d= | 	                    t           j        |           | 	                    t           j        |           | 
                    ||           | 
                    ||           t	          j                     |                     t           j        |           |                     t           j        |           |                     ||           |                     ||           d S )	Nry  rz  r{  rZ  r[  r|  r}  r  )r  r_  r`  rj  r   r   r  r   rk  r  r   r]  r  rs   )r   original_unlinkoriginal_chdirr  r  r  r  s          r   !test_patch_and_patch_dict_stopallz+PatchTest.test_patch_and_patch_dict_stopallS  s   )399;;99;;k9%%++---j.))//111
4ST**++11333
4   GO444>222D(+++D(+++bi111bh///x(((x(((((r    c                    dd}t          j        |dd          5  |                      |            d           d d d            n# 1 swxY w Y   |                      |            d           |j        }t          j        |dd          5  |                     |j        d           d d d            n# 1 swxY w Y   |                     |j        |           t          j        |dd	          5  |                     |j        d	           d d d            n# 1 swxY w Y   |                     |j        d
           t          j        |dt          dg                    5  |                     |j        t          dg                     d d d            n# 1 swxY w Y   |                     |j        t                                 ddd}t          j        |dt          dg                    5  |                      |            d           d d d            n# 1 swxY w Y   |                      |            d           d S )Nr   c                     | S )TESTr2   r  s    r   rG   z)PatchTest.test_special_attrs.<locals>.foom  s    Hr    __defaults__)r  r  __doc__FUNr"   
testpatch2z unittest.test.testmock.testpatch__annotations__)sr  r  c                     | S r   r2   )r  r4   s     r   rG   z)PatchTest.test_special_attrs.<locals>.foo  s    Hr    __kwdefaults__)r  r  )r   )r   r,   rs   r  r"   rk  r  )r   rG   orig_docs      r   test_special_attrszPatchTest.test_special_attrsl  s   	 	 	 	 \#~u55 	' 	'SSUUA&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	'""";\#y%00 	1 	1S[%000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1h///\#|\:: 	; 	;S^\:::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;)KLLL\#0$
|2D2DEE 	F 	FS0$
|2D2DEEE	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F,dff555 	 	 	 	 	\#/zl1C1CDD 	' 	'SSUUA&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	'"""""sY   AA
A
B44B8;B80DDD"*FFF4HH#&H#c                    t                      }t                      |d<   d|d<   |                                }t          t	          dt          d                              }t          |                                          |z   }t          j        |t          |                    5  | 	                    t          |                                          |           d d d            n# 1 swxY w Y   | 	                    ||           t          j        ||          5  | 	                    t          |                                          |           d d d            n# 1 swxY w Y   | 	                    ||           d S )Nr4   pythonrL   cdefghijklmnopqrstuvwxyz   )
r   r,   rj  rD  ziprangeitemsr   rk  rs   )r   rG   r   update_valuespatched_valuess        r   test_patch_orderdictzPatchTest.test_patch_orderdict  s   mm88CC88::S!;U2YYGGHHciikk**]:Z[7788 	@ 	@T#))++..???	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	h'''Z]++ 	@ 	@T#))++..???	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	h'''''s$   )6C++C/2C/!6E##E'*E'c                    dd l }t          j        d          5  t          j        d= t          j        d= t          j        d= t          j        d= t          d          d             } |             d d d            d S # 1 swxY w Y   d S )	Nr   zsys.modulesr  zunittest.test.testmockzunittest.testrO   unittest.test.testmock.support.Xc                     d S r   r2   r;  s    r   rv   z9PatchTest.test_dotted_but_module_not_loaded.<locals>.test  s    r    )unittest.test.testmock.supportr   rk  r  r  )r   rO  rv   s      r   !test_dotted_but_module_not_loadedz+PatchTest.test_dotted_but_module_not_loaded  s     	.---Z&& 
	 
	<=45O,J' 566  76DFFF
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	s   AA==BBc                     G d d          }dd |            fD ]q}|                      |          5  |                     t                    5  t          |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   rd S )Nc                       e Zd ZdS )*PatchTest.test_invalid_target.<locals>.FooNr~  r2   r    r   r0   r    r  r    r0       )r  )subTestr`   ra   r   )r   r0   r  s      r   test_invalid_targetzPatchTest.test_invalid_target  s/   	 	 	 	 	 	 	 	 2ssuuo 	" 	"FV,, " "&&y11 " "&MMM" " " " " " " " " " " " " " "" " " " " " " " " " " " " " "	" 	"s5   BA*B*A..B1A.2BB	B	c                     t          dt                      d          d             }|                     t                    5   |             d d d            d S # 1 swxY w Y   d S )Nr  r  )r>  r  c                      d S r   r2   r2   r    r   rv   z@PatchTest.test_cant_set_kwargs_when_passing_a_mock.<locals>.test  s    Dr    )r   r,   r`   ra   r   s     r   (test_cant_set_kwargs_when_passing_a_mockz2PatchTest.test_cant_set_kwargs_when_passing_a_mock  s    	1vxx1	E	E	E 
F	Ey)) 	 	DFFF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   AA!ANT)sr!   r"   r#   rf   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r&  r0  r4  r;  rH  rS  rX  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-  r6  r<  r?  rE  rH  rK  rT  r[  r]  rk  rq  ru  rx  rz  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=  rD  rG  rJ  rN  rP  rU  rX  rb  rw  r  r  r  r  r  r  r  r2   r    r   r^   r^   U   s       : : : :
/ 
/ 
/6 6 6

/ 
/ 
// / /(! ! !(> (> (>V	0 	0 	0'- '- '-T  	 	 	  	 	 	  	 	 		 	 	  6 6 68 8 86 6 64 4 4. . .(6 6 6, , ,0 0 0/ / /,/ / /4/ / / ( ( (B/ / /6( ( (>/ / /4* * *	: 	: 	:
" 
" 
"  & & &"0 0 020 0 0
+ 
+ 
+* * ** * *
+ 
+ 
+& & && & && & &>4 4 4$4 4 4$
3 
3 
3
3 
3 
3) ) )@ @ @F  ($ $ $- - -- - -? ? ?? ? ?4 4 4
 
 
  
 
 
9 9 9
' 
' 
'
' 
' 
'    *  
 
 

 
 
  && & & % % %*  >; ; ;
, , ,&, , ,*(, (, (,V, , ,2, , ,B/ / /     $0 0 024 4 4<0 0 004 4 4:, , , U,e445 5 545, U,e44> > 54>*  8 8 8  6+ + +B B BD
 
 
. . .$    	 	 	    % % %"; ; ;") ) )4) ) )2# # #6( ( (&  &" " "    r    r^   __main__r  )*r  r  collectionsr   rO  unittest.test.testmockr   r  r   r   test.test_importlib.utilr   unittest.mockr   r	   r
   r   r   r   r   r   r   r   r   r   r  r!   r   rB  r.   rm   r   r   r   r,   r0   r  rM   rO   TestCaser^   mainr2   r    r   <module>r     s  
 
			 



 # # # # # #  * * * * * * A A A A A A A A , , , , , ,                          ;x 
(
"    	(    &    h     ! ! ! ! ! ! ! !$f f f f f! f f fR; zHMOOOOO r    