3 C\@sddlZddlZddlZddlZddlmZddlmZm Z m Z ddl m Z m Z mZmZmZmZmZmZmZmZddlmZmZdZejrdZeZejeZdeZdd d Z ej!a"ej#Z$Gd d d e%Z&deZ'e&fddZ(Gddde%Z)Gdddej*Z+edkrej,dS)N)support) SomeClass is_instancecallable) NonCallableMock CallableMixinpatchsentinel MagicMockMockNonCallableMagicMockrDEFAULTcall)_patch _get_target __builtin__builtinsz %s.PTModuleTcsBGfdddt}|s<fdd}fdd}||_||_|S)NcseZdZfddZdS)z_get_proxy..Proxycs t|S)N)getattr)selfname)objj/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/mock/mock/tests/testpatch.py __getattr__ sz%_get_proxy..Proxy.__getattr__N)__name__ __module__ __qualname__rr)rrrProxysrcst||dS)N)setattr)rrvalue)rrr __setattr__#sz_get_proxy..__setattr__cst|dS)N)delattr)rr)rrr __delattr__%sz_get_proxy..__delattr__)objectr r")rget_onlyrr r"r)rr _get_proxys  r%c@s8eZdZddZddZddZdZGdd d eZd S) FoocCsdS)Nr)rarrr__init__2sz Foo.__init__cCsdS)Nr)rr'rrrf4szFoo.fcCsdS)Nr)rrrrg6szFoo.gbarc@seZdZddZdS)zFoo.BarcCsdS)Nr)rrrrr';sz Foo.Bar.aN)rrrr'rrrrBar:sr,N) rrrr(r)r*foor#r,rrrrr&1s r&z%s.FoocCsdS)Nr)r'brrrfunctionAsr/c@s4eZdZddZddZddZddZd d Zd S) ContainercCs i|_dS)N)values)rrrrr(FszContainer.__init__cCs |j|S)N)r1)rrrrr __getitem__IszContainer.__getitem__cCs||j|<dS)N)r1)rrrrrr __setitem__LszContainer.__setitem__cCs |j|=dS)N)r1)rrrrr __delitem__OszContainer.__delitem__cCs t|jS)N)iterr1)rrrr__iter__RszContainer.__iter__N)rrrr(r2r3r4r6rrrrr0Es r0c@sXeZdZdddZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Zdd?Z!d@dAZ"dBdCZ#dDdEZ$e%j&dFdGZ'dHdIZ(dJdKZ)dLdMZ*dNdOZ+dPdQZ,dRdSZ-dTdUZ.dVdWZ/dXdYZ0dZd[Z1d\d]Z2d^d_Z3d`daZ4dbdcZ5dddeZ6dfdgZ7dhdiZ8djdkZ9dldmZ:dndoZ;dpdqZdvdwZ?dxdyZ@dzd{ZAd|d}ZBd~dZCddZDddZEddZFddZGddZHddZIddZJddZKddZLddZMddZNddZOddZPddZQddZRddZSddZTeUddddZVeUddddZWddZXddZYddZZddZ[ddZ\ddZ]ddZ^ddZ_ddZ`ddZaddZbddZcdd„ZdddĄZeddƄZfddȄZgddʄZhdd̄Zidd΄ZjddЄZkdS) PatchTestTcCs<t}|s t}|jt||jt|||jt|tdS)N)r r assertRaises TypeError assertTruer assertFalser)rrmagic MockClassrrrassertNotCallableYs  zPatchTest.assertNotCallablecsJGdddttjdtjfdd}|jjtjddS)Nc@seZdZejZdS)z4PatchTest.test_single_patchobject..SomethingN)rrrr Original attributerrrr SomethingdsrAr@csjjtjddS)N unpatched) assertEqualr@r Patchedr)rArrrtestgsz/PatchTest.test_single_patchobject..testzpatch not restored)r#rr rDrCr@r?)rrEr)rArrtest_single_patchobjectcs  z!PatchTest.test_single_patchobjectcsHGdddttjddfdd}|jjtjddS)Nc@seZdZejZdS)z7PatchTest.test_patchobject_with_none..SomethingN)rrrr r?r@rrrrrAqsrAr@csjjddS)NrB) assertIsNoner@r)rArrrrEtsz2PatchTest.test_patchobject_with_none..testzpatch not restored)r#rrCr@r r?)rrEr)rArrtest_patchobject_with_noneps  z$PatchTest.test_patchobject_with_nonecslGdddttjdtjtjdtjfdd}|jjtjdjjtj ddS)Nc@seZdZejZejZdS)z6PatchTest.test_multiple_patchobject..SomethingN)rrrr r?r@ Original2next_attributerrrrrA~srAr@rJcs(jjtjdjjtjddS)NrB)rCr@r rDrJPatched2r)rArrrrEs  z1PatchTest.test_multiple_patchobject..testzpatch not restored) r#rr rDrKrCr@r?rJrI)rrEr)rArrtest_multiple_patchobject}s   z#PatchTest.test_multiple_patchobjectc CsFt}tdttjdd}ztja||jttjWd|aXdS)Nz %s.somethingcSsdS)NrrrrrrEsz8PatchTest.test_object_lookup_is_quite_lazy..test) somethingrrr Something2Zreplacement_valuerC)roriginalrErrr test_object_lookup_is_quite_lazysz*PatchTest.test_object_lookup_is_quite_lazycstdttjfdd}|jtjtjdtdttjtdttjfdd}jtjtjdjtj tjd|jtjtjdjtj tjdt }tj |_ tdt |fdd}||jt|ddS) Nz %s.somethingcsjtjtjddS)NrB)rCPTModulerMr rNr)rrrrEs z"PatchTest.test_patch..testzpatch not restoredz%s.something_elsecs(jtjtjdjtjtjddS)NrB)rCrQrMr rNsomething_else SomethingElser)rrrrEs  z%s.opencsjtddtjddS)Nfilenamerzopen not patched)rCopenr Handler)rrrrEs)rrr rNrCrQrMrArSrRr rW return_valuebuiltin_stringassertNotEqualrV)rrEmockr)rr test_patchs*     zPatchTest.test_patchcs6tdttjfdd}|jtjjddS)Nz%s.SomeClass.class_attributecsjtjjtjddS)NrB)rCrQrclass_attributer ClassAttributer)rrrrEs z2PatchTest.test_patch_class_attribute..testzpatch not restored)rrr r^rGrQrr])rrEr)rrtest_patch_class_attributes  z$PatchTest.test_patch_class_attributecsGdddttjdfdd}|tjdtjdfdd}d|tjtj\|tjtjdS)Nc@seZdZejZejZdS)z:PatchTest.test_patchobject_with_default_mock..TestN)rrrr r?rMrI something2rrrrTestsrarMcs"j|jdj|tddS)Nz"Mock not passed into test functionz.patch with two arguments did not create a mock)rCrMassertIsInstancer )r[)rarrrrEs z:PatchTest.test_patchobject_with_default_mock..testr`csj|tjdj|tjdj|jdj|jdj|tdj|tdj|dj|d||fS)Nz0Patched function didn't receive initial argumentz/Patched function didn't receive second argumentz"Mock not passed into test functionz)Second Mock not passed into test functionz.patch with two arguments did not create a mockzunexpected value for mock1) rCr this1this2r`rMrbr rZ)rcrdZmock1Zmock2)ra outerMock1 outerMock2rrrrEs    )r#rr rcrd)rrEr)rarerfrr"test_patchobject_with_default_mocks  z,PatchTest.test_patchobject_with_default_mockcs&tdttdfdd}|dS)Nz %s.SomeClass)speccs2jt|jttjtjtdddS)NcSstjS)N)r not_wibblerrrrsz>PatchTest.test_patch_with_spec..test..)rCrr:rwibbler r8AttributeError) MockSomeClass)rrrrEs z,PatchTest.test_patch_with_spec..test)rrr)rrEr)rrtest_patch_with_specszPatchTest.test_patch_with_speccs&tjtdtdfdd}|dS)Nr])rhcs6jtj|jttjjtjtdddS)NcSstjjS)N)rr]rirrrrrjszDPatchTest.test_patchobject_with_spec..test..) rCrr]r:rrkr r8rl) MockAttribute)rrrrE s  z2PatchTest.test_patchobject_with_spec..test)rr#r)rrEr)rrtest_patchobject_with_spec sz$PatchTest.test_patchobject_with_speccs(tdtdgdfdd}|dS)Nz %s.SomeClassrk)rhcs2jt|jttjtjtdddS)NcSstjS)N)rrirrrrrjszFPatchTest.test_patch_with_spec_as_list..test..)rCrr:rrkr r8rl)rm)rrrrEs z4PatchTest.test_patch_with_spec_as_list..test)rr)rrEr)rrtest_patch_with_spec_as_listsz&PatchTest.test_patch_with_spec_as_listcs(tjtddgdfdd}|dS)Nr]rk)rhcs6jtj|jttjjtjtdddS)NcSstjjS)N)rr]rirrrrrj(szLPatchTest.test_patchobject_with_spec_as_list..test..) rCrr]r:rrkr r8rl)ro)rrrrE"s  z:PatchTest.test_patchobject_with_spec_as_list..test)rr#r)rrEr)rr"test_patchobject_with_spec_as_list!sz,PatchTest.test_patchobject_with_spec_as_listcs4tdttdtdgdfdd}|dS)Nz%s.openz %s.SomeClassrk)rhcs2jt|jttjtjtdddS)NcSstjS)N)rrirrrrrj4szMPatchTest.test_nested_patch_with_spec_as_list..test..)rCrr:rrkr r8rl)rmZMockOpen)rrrrE/s z;PatchTest.test_nested_patch_with_spec_as_list..test)rrYr)rrEr)rr#test_nested_patch_with_spec_as_list-s  z-PatchTest.test_nested_patch_with_spec_as_listcs&tdtddfdd}|dS)Nz %s.SomeClassT)rhcs*jtjjtfdddS)NcsjS)N)rir)rmrrrj?szIPatchTest.test_patch_with_spec_as_boolean..test..)rCrrkr8rl)rm)r)rmrrE9s z7PatchTest.test_patch_with_spec_as_boolean..test)rr)rrEr)rrtest_patch_with_spec_as_boolean8sz)PatchTest.test_patch_with_spec_as_booleancs&tjtdddfdd}|dS)NrT)rhcs*jtjjtfdddS)NcsjS)N)rir)rmrrrjKszPPatchTest.test_patch_object_with_spec_as_boolean..test..)rCrrkr8rl)rm)r)rmrrEEs z>PatchTest.test_patch_object_with_spec_as_boolean..test)rr#rQ)rrEr)rr&test_patch_object_with_spec_as_booleanDsz0PatchTest.test_patch_object_with_spec_as_booleancs&tdtddfdd}|dS)Nz %s.SomeClassT)rhcs>jt|t|jjjtfdddS)NcsjS)N)rir)instancerrrjYszVPatchTest.test_patch_class_acts_with_spec_is_inherited..test..)r:rr r>rkr8rl)rm)r)rvrrEQs  zDPatchTest.test_patch_class_acts_with_spec_is_inherited..test)rr)rrEr)rr,test_patch_class_acts_with_spec_is_inheritedPs z6PatchTest.test_patch_class_acts_with_spec_is_inheritedcs:tdttjddfdd}|jtdddS)Nz %s.froobleT)createcsjttjdS)N)rCfroobler Froobler)rrrrE_szLPatchTest.test_patch_with_create_mocks_non_existent_attributes..testcSstS)N)ryrrrrrjdszPPatchTest.test_patch_with_create_mocks_non_existent_attributes..)rrYr rzr8 NameError)rrEr)rr4test_patch_with_create_mocks_non_existent_attributes^s z>PatchTest.test_patch_with_create_mocks_non_existent_attributescs:tjtdtjddfdd}|jttddS)NryT)rxcsjtjtjdS)N)rCrryr rzr)rrrrEhszRPatchTest.test_patchobject_with_create_mocks_non_existent_attributes..test)rr#rr rzr;hasattr)rrEr)rr:test_patchobject_with_create_mocks_non_existent_attributesgs zDPatchTest.test_patchobject_with_create_mocks_non_existent_attributesc sZy&tdttjfdd}|Wntk r:Yn XjdjtdddS)Nz %s.frooblecsjttjdS)N)rCryr rzr)rrrrErsz9PatchTest.test_patch_wont_create_by_default..testz,Patching non existent attributes should failcSstS)N)ryrrrrrj|sz=PatchTest.test_patch_wont_create_by_default..)rrYr rzrlfailr8r{)rrEr)rr!test_patch_wont_create_by_defaultps  z+PatchTest.test_patch_wont_create_by_defaultc sZy&tjtdtjfdd}|Wntk r:Yn XjdjttddS)NordcsjddS)Nz,Patching non existent attributes should fail)rr)rrrrEsz?PatchTest.test_patchobject_wont_create_by_default..testz,Patching non existent attributes should fail) rr#rr rzrlrr;r})rrEr)rr'test_patchobject_wont_create_by_defaults  z1PatchTest.test_patchobject_wont_create_by_defaultcCsHttddd}ttddd}|j|d|j|ddS) Nz.ordcSsd|_tdS)Nec)rXr)Zmock_ordrrrtest_ordsz>PatchTest.test_patch_builtins_without_create..test_ordz.opencSs*|j}d|j_td}|j}|j|S)Nabcdzdoesnotexists.txt)rXreadrVclose)Z mock_openmZfobjdatarrr test_opens z?PatchTest.test_patch_builtins_without_create..test_openrr)rrrC)rrrrrr"test_patch_builtins_without_creates z,PatchTest.test_patch_builtins_without_createcsPGdddttjdtddfdd}|jjtjdS)Nc@seZdZeddZdS)z5PatchTest.test_patch_with_static_methods..FoocSstjS)N)r Staticrrrrwootsz:PatchTest.test_patch_with_static_methods..Foo.wootN)rrr staticmethodrrrrrr&sr&rcSstjS)N)r rDrrrrrjsz:PatchTest.test_patch_with_static_methods..csjjtjdS)N)rCrr rDr)r&rrr anonymoussz;PatchTest.test_patch_with_static_methods..anonymous)r#rrrCrr r)rrr)r&rrtest_patch_with_static_methodss$z(PatchTest.test_patch_with_static_methodscs8tj}tjtddfdd}|jtj|dS)Nr&csjtjddS)Nr&)rCr r&r)rrrrsz-PatchTest.test_patch_local..anonymous)r r&rr#rC)rr-rr)rrtest_patch_localszPatchTest.test_patch_localcsTGdddt}|tj_tjddfdd}|jjtjdS)Nc@seZdZdZdS)z'PatchTest.test_patch_slots..Foor&N)r&)rrr __slots__rrrrr&sr&csjjddS)Nr&)rCr&r)r-rrrrsz-PatchTest.test_patch_slots..anonymous)r#r r&rrC)rr&rr)r-rrtest_patch_slotss zPatchTest.test_patch_slotscsfGdddtGfdddt}tjdtj|}|}|j|jjjtjddS)Nc@seZdZejZdS)z=PatchTest.test_patchobject_class_decorator..SomethingN)rrrr r?r@rrrrrAsrAcs(eZdZfddZfddZdS)z7PatchTest.test_patchobject_class_decorator..FoocsjjtjddS)NrB)rCr@r rD) other_self)rArrr test_methods zCPatchTest.test_patchobject_class_decorator..Foo.test_methodcsjjtjddS)Nznon-test method patched)rCr@r r?)r)rArrrnot_test_methods zGPatchTest.test_patchobject_class_decorator..Foo.not_test_methodN)rrrrrr)rArrrr&sr&r@zpatch not restored) r#rr rDrrrCr@r?)rr&r)r)rArr test_patchobject_class_decorators z*PatchTest.test_patchobject_class_decoratorcsrGdddt}Gfdddt}tdt|}|}|j|jj|jtjdjt j tj ddS)Nc@seZdZejZdS)z7PatchTest.test_patch_class_decorator..SomethingN)rrrr r?r@rrrrrAsrAcs$eZdZfddZfddZdS)z1PatchTest.test_patch_class_decorator..Foocsjtj|ddS)NrB)rCrQrM)rZmock_something)rrrrs z=PatchTest.test_patch_class_decorator..Foo.test_methodcsjtjtjddS)Nznon-test method patched)rCrQrMr rA)r)rrrrs zAPatchTest.test_patch_class_decorator..Foo.not_test_methodN)rrrrrr)rrrr&s r&z %s.somethingzpatch not restored) r#rrrrrCr@r r?rQrMrA)rrAr&r)r)rrtest_patch_class_decorators  z$PatchTest.test_patch_class_decoratorcsZGdddttjdtjtjdtjfdd}|jjtjddS)Nc@seZdZejZejZdS)z3PatchTest.test_patchobject_twice..SomethingN)rrrr r?r@rIrJrrrrrAsrAr@csjjtjddS)NrB)rCr@r rDr)rArrrrEsz.PatchTest.test_patchobject_twice..testzpatch not restored)r#rr rDrCr@r?)rrEr)rArrtest_patchobject_twices   z PatchTest.test_patchobject_twicecstddj}tjfdd}|j|tjddifdd}|j|tjd gfdd}|j|dS) NrM)initialothercsdd<d=dd<dS)Nr'rzsomething elserrr)r-rrrE sz'PatchTest.test_patch_dict..testr'r.cs$jtdjdddS)Nrr'r.)rClenr)r-rrrrEscs$jtdjdddS)Nrr'r.)rCrr)r-rrrrEs)r'r.)r#copyrdictrC)rrOrEr)r-rrtest_patch_dicts   zPatchTest.test_patch_dictcsttd<dd<jj}tjfdd}|jj|tjddifdd}|jj|dS) NrrMrcsdd<d=dd<dS)Nrr'rzsomething elserrr)r-rrrE-sz=PatchTest.test_patch_dict_with_container_object..testr'r.cs&jtjdjdddS)Nrr'r.)rCrr1r)r-rrrrE7s)r0r#r1rrrrC)rrOrEr)r-rr%test_patch_dict_with_container_object&s  z/PatchTest.test_patch_dict_with_container_objectcstddj}tjddfdd}|j|tjddiddfd d}|j|tjd gddfd d}|j|dS) NrM)rrT)clearcs jidd<dd<dS)Nrr'zsomething elser)rCr)r-rrrrEEs z2PatchTest.test_patch_dict_with_clear..testr'r.csjddidS)Nr'r.)rCr)r-rrrrEOscsjddidS)Nr'r.)rCr)r-rrrrEWs)r'r.)r#rrrrC)rrOrEr)r-rrtest_patch_dict_with_clearAs  "  z$PatchTest.test_patch_dict_with_clearcsttd<dd<jj}tjddfdd}|jj|tjdd iddfd d}|jj|dS) NrrMrT)rcs"jjidd<dd<dS)Nrr'zsomething elser)rCr1r)r-rrrrEgszGPatchTest.test_patch_dict_with_container_object_and_clear..testr'r.csjjddidS)Nr'r.)rCr1r)r-rrrrEqs)r0r#r1rrrrC)rrOrEr)r-rr/test_patch_dict_with_container_object_and_clear`s  "z9PatchTest.test_patch_dict_with_container_object_and_clearcCsZi}tdtttdttddtjtttj|dd}|j|jddS)Nz %s.SomeClassT)autospeccSsdS)Nrrrrr some_name}sz0PatchTest.test_name_preserved..some_namer)rrr#rrrC)rr-rrrrtest_name_preservedzs  zPatchTest.test_name_preservedc CsVi}tj|ddidd}y |Wntk r:Yn X|jd|j|idS)Nr'r.cSs tddS)NZKonrad)r{rrrrrEsz1PatchTest.test_patch_with_exception..testzNameError not raised by test)rrr{rrC)rr-rErrrtest_patch_with_exceptions  z#PatchTest.test_patch_with_exceptioncs&tjdddifdd}|dS)Nz os.environ konrad_delongz some valuecsjdtjdS)Nr)assertInosenvironr)rrrrEsz3PatchTest.test_patch_dict_with_string..test)rr)rrEr)rrtest_patch_dict_with_stringsz%PatchTest.test_patch_dict_with_stringcsGdddtGfdddtjjddjjjddj}j|jdd|jj|jdd|jdS)Nc@seZdZdZdS)z0PatchTest.test_patch_descriptor..NothingN)rrrr-rrrrNothingsrcs|eZdZiZejddefddZejddeddZ ej eefddZ ej eed d Z d S) z2PatchTest.test_patch_descriptor..Somethingr-csj|dS)N)assertIs)cls)rArrrklasssz8PatchTest.test_patch_descriptor..Something.klasscSs|S)Nr)argrrrstaticsz9PatchTest.test_patch_descriptor..Something.staticcsj|dS)N)r)r)rArrr klass_dictsz=PatchTest.test_patch_descriptor..Something.klass_dictcSs|S)Nr)rrrr static_dictsz>PatchTest.test_patch_descriptor..Something.static_dictN) rrrr-rr# classmethodrrrrrrr)rrArrrrAs  rAZf00)r#rCrrrr)rrMr)rrArrtest_patch_descriptorszPatchTest.test_patch_descriptorcCstdttddd}|jt|tjtdtddd}|jt|tdtdddd}|jt|tjtdddd d}|jt|dS) Nz %s.SomeClass)spec_setcSs d|_dS)Nr-)z)r=rrrrEsz+PatchTest.test_patch_spec_set..testrcSs d|_dS)Nr-)r)r=rrrrEsTcSs d|_dS)Nr-)r)r=rrrrEscSs d|_dS)Nr-)r)r=rrrrEs)rrrr8rlr#r)rrErrrtest_patch_spec_sets   zPatchTest.test_patch_spec_setcCs(tdtdddd}|jt|dS)Nz %s.SomeClassT)rcSs|}d|_dS)Nr-)r)r=rvrrrrEsz-PatchTest.test_spec_set_inherit..test)rrr8rl)rrErrrtest_spec_set_inheritszPatchTest.test_spec_set_inheritc Cs\t}tdt}|jt||j}z|j|||jt|Wd|jX|jt|dS)Nz %s.something)rMrrrstart assertIsNotstop)rrOpatcherr[rrrtest_patch_start_stops    zPatchTest.test_patch_start_stopcCsttdd}|jt|jdS)Nr+r)rfoo_namer8 RuntimeErrorr)rrrrrtest_stop_without_starts z!PatchTest.test_stop_without_startc Cs^t}tjtdd}|jt||j}z|j|d|jt|Wd|jX|jt|dS)NrMr-)rMrr#rQrrrCr)rrOrZreplacedrrrtest_patchobject_start_stops   z%PatchTest.test_patchobject_start_stopc Csfddi}|j}tj|dgdd}|j|||jz|j|ddiWd|jX|j||dS)Nr-r+spameggsT)r)rr)rrrrCrr)rdrOrrrrtest_patch_dict_start_stop s  z$PatchTest.test_patch_dict_start_stopcs|ddij}Gfdddt}tjddidd|}|j||}|j|j||j|j||}|j|j||j|j|dS) Nrrcs(eZdZfddZfddZdS)z7PatchTest.test_patch_dict_class_decorator..TestcsjddidS)Nr-r+)rC)r)rthisrr test_first!szBPatchTest.test_patch_dict_class_decorator..Test.test_firstcsjddidS)Nr-r+)rC)r)rrrr test_second#szCPatchTest.test_patch_dict_class_decorator..Test.test_secondN)rrrrrr)rrrrra srar-r+T)r)rr#rrrCrr)rrOrarEr)rrrtest_patch_dict_class_decorators     z)PatchTest.test_patch_dict_class_decoratorcsGdddt}Gddd}xj||||fD]X}t|tjddfdd}|jjdj|jdjdjq.WdS) Nc@seZdZdZdS)z0PatchTest.test_get_only_proxy..Somethingr-N)rrrr-rrrrrA;srAc@seZdZdZdS)z4PatchTest.test_get_only_proxy..SomethingElser-N)rrrr-rrrrrS=srSr-r+csjjddS)Nr+)rCr-r)proxyrrrrECsz+PatchTest.test_get_only_proxy..test)r#r%rrCr- assertNotIn__dict__)rrArSthingrEr)rrrtest_get_only_proxy:szPatchTest.test_get_only_proxycsGdddt}Gddd}xn||||fD]\}t|ddtjddfd d }|jjdj|jdjdjq.WdS) Nc@seZdZdZdS)z6PatchTest.test_get_set_delete_proxy..Somethingr-N)rrrr-rrrrrAMsrAc@seZdZdZdS)z:PatchTest.test_get_set_delete_proxy..SomethingElser-N)rrrr-rrrrrSOsrSF)r$r-r+csjjddS)Nr+)rCr-r)rrrrrEUsz1PatchTest.test_get_set_delete_proxy..test)r#r%rrCr-rr)rrArSrrEr)rrrtest_get_set_delete_proxyLs z#PatchTest.test_get_set_delete_proxycCsZtdtd}ttf|}|j}|j|jt||j|jj d|j |jtdS)N!) side_effectzfoo.bar.return_valuer-) KeyErrorr rrrrr8rCr-r+rb)rkwargsrr[rrrtest_patch_keyword_args^s   z!PatchTest.test_patch_keyword_argscCs^tdtd}tjtdf|}|j}|j|jt||j|j j d|j |j tdS)Nr)rzfoo.bar.return_valuer-r)) rr rr#r&rrr8rCr-r+rb)rrrr[rrrtest_patch_object_keyword_argsks  z(PatchTest.test_patch_object_keyword_argsc Cs`ddi}|j}tj|dddd}|jz|j|tddddWd|jX|j||dS)Nr-r+r)r-r+Zbaz)rrrrrCr)rrOrrrrrtest_patch_dict_keyword_argsxs z&PatchTest.test_patch_dict_keyword_argscsGdddt}fddfddfdd}ttd d |}|}jt||tjt}tj|d d d |}|}jt||dS) Nc@s8eZdZddZddZddZdZGdd d eZd S) z$PatchTest.test_autospec..BoocSsdS)Nr)rr'rrrr(sz-PatchTest.test_autospec..Boo.__init__cSsdS)Nr)rr'rrrr)sz&PatchTest.test_autospec..Boo.fcSsdS)Nr)rrrrr*sz&PatchTest.test_autospec..Boo.gr+c@seZdZddZdS)z(PatchTest.test_autospec..Boo.BarcSsdS)Nr)rrrrr'sz*PatchTest.test_autospec..Boo.Bar.aN)rrrr'rrrrr,sr,N) rrrr(r)r*r-r#r,rrrrBoos rcs"|d|jdjt|dS)N)assert_called_withr8r9)r[)rrr_tests z&PatchTest.test_autospec.._testcs|jd|jjdjt|j|j|jjjt|jdjtt|d|jj|jjjjtt|jd|j |j j|j j |j j jjt|j j d|j j |j j jjt|j j djtt|j djtt|j ddS)Nrhr+r.) r)rr8r9r*rlrr-lowerr,r')r[)rrr_test2s(         z'PatchTest.test_autospec.._test2cs,|||dj|t|S)Nr)rr&)r[)rrrrrr/s   z)PatchTest.test_autospec..functionT)rr&)r#rrrr&sysmodulesr)rrr/rEr[moduler)rrrr test_autospecs     zPatchTest.test_autospeccs&tdtddfdd}|dS)Nz %s.functionT)rcsHtdtjdtddtjddjttjtttddS)Nrrrr-)r/rr8r9rlr)r[)rrrrEs     z.PatchTest.test_autospec_function..test)rr)rrEr)rrtest_autospec_functions z PatchTest.test_autospec_functioncCs0tdtddddd}|}|j|ddS)Nz %s.functionTr)rrXcSs tddS)Nrr)r/)Z mock_functionrrrrEsz.PatchTest.test_autospec_keywords..test)rrrC)rrEresultrrrtest_autospec_keywordss z PatchTest.test_autospec_keywordscCsNtdtddd}|jt|jtjt}tj|dddd}|jt|jdS)Nz %s.functionrT)newrr/)rrr8r9rrrr#)rrrrrrtest_autospec_with_news  z PatchTest.test_autospec_with_newc CsRGdddt}tt|d}|j}z|j|||j|jtWd|jXdS)Nc@seZdZgZdS)z0PatchTest.test_autospec_with_object..BarN)rrrextrarrrrr,sr,)r)r&rrrrbrlistr)rr,rr[rrrtest_autospec_with_objects  z#PatchTest.test_autospec_with_objectc CsHt}ttdd}|j}z |j|||j|d|Wd|jXdS)NT)rr)r&rrrrbr)rZFooClassrr[rrrtest_autospec_inheritss  z PatchTest.test_autospec_inheritsc Cstttdd}|j}zP|jdt||jdt|j|jdt|d|jdt|djWd|jXdS)NT)rz name='Foo'z name='Foo.f'z name='Foo()'z name='Foo().f')rrrrreprr)r)rrr[rrrtest_autospec_names zPatchTest.test_autospec_namec Csbtjtdtdd}y |Wntj}YnXtjddd}|j||}|jd|dS)Nr)cSstdS)N)AssertionErrorrrrrrEsz'PatchTest.test_tracebacks..testrzraise AssertionError) rr#r&rexc_infounittestZTextTestResultZ_exc_info_to_stringr)rrEerrr tracebackrrrtest_tracebackss  zPatchTest.test_tracebackscCsXtttd}|j}|j|j}|j|j||x||fD]}|j|qBWdS)N) new_callable)rrr rrrr>)rrm1m2r[rrrtest_new_callable_patch#s  z!PatchTest.test_new_callable_patchcCs\tjtdtd}|j}|j|j}|j|j||x||fD]}|j|qFWdS)Nr))r)rr#r&r rrrr>)rrrrr[rrrtest_new_callable_patch_object0s z(PatchTest.test_new_callable_patch_objectc sfGfdddtttddd}|j}z*|jt||jjtdddWd|j XdS)NcseZdZdZfddZdS)z:PatchTest.test_new_callable_keyword_arguments..BarNcs |_dS)N)r)rr)r,rrr(@szCPatchTest.test_new_callable_keyword_arguments..Bar.__init__)rrrrr(r)r,rrr,>sr,rr)rarg1arg2)rr) r#rrrrtyperCrrr)rrrr)r,r#test_new_callable_keyword_arguments=sz-PatchTest.test_new_callable_keyword_argumentscsGfdddtttd}|jz|jjtdWd|jXttd}|jz|jjtdWd|jXdS)NcseZdZdZfddZdS)z-PatchTest.test_new_callable_spec..BarNcs |_dS)N)r)rr)r,rrr(Osz6PatchTest.test_new_callable_spec..Bar.__init__)rrrrr(r)r,rrr,Msr,)rrh)rh)rr)r)r#rrrrCrrr)rrr)r,rtest_new_callable_specLs z PatchTest.test_new_callable_specc CsZdt}t|td}|jt|jt|tdd}|j}z|j|ddWd|jXdS)Nz %s.weeeee)rT)rrxF)r<)rrrr8rlrr>r)rZnon_existent_attrprrrrtest_new_callable_createas z"PatchTest.test_new_callable_createcCs4|jtttttd|jttjtdttddS)N)rrr))r8 ValueErrorrrr#r r&)rrrr'test_new_callable_incompatible_with_newos z1PatchTest.test_new_callable_incompatible_with_newcCs0|jttttdd|jttjtdtdddS)NT)rrr))r8rrrr r#r&)rrrr,test_new_callable_incompatible_with_autospecys  z6PatchTest.test_new_callable_incompatible_with_autospecc CsGdddt}tttt|f}xd|D]\}xVdD]N}|di}ttfd|i|}|j}z|j}|jt t |dWd|j Xq.Wq$WdS) Nc@s eZdZdS)z>PatchTest.test_new_callable_inherit_for_mocks..MockSubN)rrrrrrrMockSubsr rhrTrx)rhr) r rr r rrrrXr8rlrr) rr Z MockClassesZKlassrrrrrvrrr#test_new_callable_inherit_for_mockss  z-PatchTest.test_new_callable_inherit_for_mocksc CshGdddt}tt|dd}|j}z$|jt|||jtt|dWd|j X|j |j t dS)Nc@seZdZddZdS)z>PatchTest.test_new_callable_inherit_non_mock..NotAMockcSs ||_dS)N)rh)rrhrrrr(szGPatchTest.test_new_callable_inherit_non_mock..NotAMock.__init__N)rrrr(rrrrNotAMocksr T)rrhrX) r#rrrr:rr8rlrrrCrhr&)rr rrrrr"test_new_callable_inherit_non_mocks z,PatchTest.test_new_callable_inherit_non_mockcsR|tGfdddt}tttd|}|j|j|jtdS)Ncs*eZdZfddZddZddZdS)z>PatchTest.test_new_callable_class_decorating..SomeTestcs(jtjt|jttdS)N)rr&rrbr)rmock_foo)rOrErrrs  zDPatchTest.test_new_callable_class_decorating..SomeTest._testcSs|j|dS)N)r)rrrrrtest_twoszGPatchTest.test_new_callable_class_decorating..SomeTest.test_twocSs|j|dS)N)r)rrrrrtest_oneszGPatchTest.test_new_callable_class_decorating..SomeTest.test_oneN)rrrrrrr)rOrErrSomeTestsr)r)r&r#rrrrrr)rrr)rOrEr"test_new_callable_class_decoratings   z,PatchTest.test_new_callable_class_decoratingc sttj}tj}tjtddd}tjtddd}xx||fD]l}|jz,jtjtjdjtjdWd|j Xjtjtj|jtj|q:Wtjtdddfdd}|dS)Nrr)r)r*rrcs,jtjtjdjtjddS)Nrr)rr&rCr)r*r) original_foorrrrEs z+PatchTest.test_patch_multiple..test) r&r)r*rmultiplerrrrCr)r original_f original_gZpatcher1Zpatcher2rrEr)rrrtest_patch_multiples"   zPatchTest.test_patch_multiplecCs$|jttjt|jttjtdS)N)r8rrrrr&)rrrrtest_patch_multiple_no_kwargssz'PatchTest.test_patch_multiple_no_kwargscsVttj}tj}tjttdtdfdd}|jtj|jtj|dS)Nr)r)r*r-csZjtjtj|jtjdjtj|jt|tjt|tdS)Nr) rr&r)rCr*r-r:rr )r)r-)rrrrrEs  z8PatchTest.test_patch_multiple_create_mocks..test)r&r)r*rrrr rC)rrrrEr)rrr test_patch_multiple_create_mockss z*PatchTest.test_patch_multiple_create_mockscsrtj}tj}tjtdd}d|_tjtdt}d|_|g|_|fdd}|jtj|jtj|dS)Nr)rr*cs jtj|jtjddS)Nr)rr&r*rCr))r*)rrrrEszHPatchTest.test_patch_multiple_create_mocks_different_order..test) r&r)r*rr#attribute_namer additional_patchersrC)rrrrrrEr)rr0test_patch_multiple_create_mocks_different_ordersz:PatchTest.test_patch_multiple_create_mocks_different_ordercsttj}tj}tjttdtjttdttdfdd}tjttdttdtjttdfdd}ttdtjttdtjttdfdd }fd d |||jtj|jtj|dS) N)r))r-z.gcs|f|dS)Nr)r*r)rrrtest1sz?PatchTest.test_patch_multiple_stacked_decorators..test1cs|f|dS)Nr)r*r)rrrtest2sz?PatchTest.test_patch_multiple_stacked_decorators..test2cs|f|dS)Nr)r*r)rrrtest3sz?PatchTest.test_patch_multiple_stacked_decorators..test3cs|jd}|jd}j|jtjtj|jtj|jtj|jt|t jt|t jt|t dS)Nr)r-) popr;rr&r)r*r-r:rr )r*rr)r-)rrrrr s    z?PatchTest.test_patch_multiple_stacked_decorators.._test)r&r)r*rrrr rC)rrrrrrr)rrrr&test_patch_multiple_stacked_decorators s$       z0PatchTest.test_patch_multiple_stacked_decoratorsc Cst}tj}tj}tjttdtd}|j}zt|d}|d}|jt |t ddg|j t||j tj||j tj ||j t |t|j t |tWd|jX|jtj||jtj|dS)Nr)r)r*r-r)r-)r&r)r*rrrr rrCsetrr-r:rr r)rrrrrrr)r-rrr(test_patch_multiple_create_mocks_patcher4s"  z2PatchTest.test_patch_multiple_create_mocks_patchercsv|ttj}tj}Gfdddt}tjttdtd|}|}|j|j |j tj||j tj|dS)Ncs*eZdZfddZddZddZdS)z@PatchTest.test_patch_multiple_decorating_class..SomeTestcsZjtjtj|jtjdjtj|jt|tjt|tdS)Nr) rr&r)rCr*r-r:rr )rr)r-)rrErrrUs  zFPatchTest.test_patch_multiple_decorating_class..SomeTest._testcSs|j||dS)N)r)rr)r-rrrr]szIPatchTest.test_patch_multiple_decorating_class..SomeTest.test_twocSs|j||dS)N)r)rr)r-rrrr_szIPatchTest.test_patch_multiple_decorating_class..SomeTest.test_oneN)rrrrrrr)rrErrrSsrr)r)r*r-) r&r)r*r#rrrr rrrC)rrrrrr)rrEr$test_patch_multiple_decorating_classMs z.PatchTest.test_patch_multiple_decorating_classc Csftjtdd}|jt|jtjtddd}|jz|jtjdWd|jX|j t tddS)Nblam)r%T)r%rx) rrr&r8rlrrCr%rr;r})rrrrrtest_patch_multiple_createns z$PatchTest.test_patch_multiple_createc Cstjttddgd}|j}z^|jtj|dtjjdtjjdtjjj dtjjj d|j t t tjddWd|j XdS)Nr'r.)r-rr-rrr)rrr&r rrCr-r'r.rr8rlrr)rrrrrrtest_patch_multiple_spec_set|s  z&PatchTest.test_patch_multiple_spec_setc CsGdddt}tjttt|d}|j}zT|jtj|d|jtj|d|j tj||j tj||j tjtjWd|j XdS)Nc@s eZdZdS)z9PatchTest.test_patch_multiple_new_callable..ThingN)rrrrrrrThingsr()r)r*rr)r*) r#rrr&r rrr)r*rbrr)rr(rrrrr test_patch_multiple_new_callablesz*PatchTest.test_patch_multiple_new_callablecCstj}tj}tjtddtjtddtjtdddd}tjtddtjtddtjtdddd}tjtddtjtddtjtddd d }x:|||fD],}|jt||jtj||jtj|qWdS) Nr*rmissingr)cSsdS)Nrrrrrthing1sz3PatchTest.test_nested_patch_failure..thing1cSsdS)Nrrrrrthing2sz3PatchTest.test_nested_patch_failure..thing2cSsdS)Nrrrrrthing3sz3PatchTest.test_nested_patch_failure..thing3)r&r)r*rr#r8rlrC)rrrr+r,r-funcrrrtest_nested_patch_failures       z#PatchTest.test_nested_patch_failurec Cstj}tj}tj}dd}tjtddtjtd|dtjtdddd }tjtd|dtjtddtjtddd d }tjtddtjtddtjtd|dd d }xH|||fD]:}|jt||jtj||jtj||jtj|qWdS)NcSs tddS)Ncrasher)r{rrrrr0sz4PatchTest.test_new_callable_failure..crasherr*rr-)rr)cSsdS)Nrrrrrr+sz3PatchTest.test_new_callable_failure..thing1cSsdS)Nrrrrrr,sz3PatchTest.test_new_callable_failure..thing2cSsdS)Nrrrrrr-sz3PatchTest.test_new_callable_failure..thing3) r&r)r*r-rr#r8r{rC) rrrrr0r+r,r-r.rrrtest_new_callable_failures$     z#PatchTest.test_new_callable_failurecCstj}tj}tjtdd}d|_tjtdd}d|_tjtdd}d|_xR||g||gfD]>}||_|dd}|jt||j tj||j tj|qZWdS)Nr)rr*r*cSsdS)Nrrrrrr.sz3PatchTest.test_patch_multiple_failure..func) r&r)r*rr#rrr8rlrC)rrrrgoodbad additionalsr.rrrtest_patch_multiple_failures  z%PatchTest.test_patch_multiple_failurec Cstj}tj}tj}dd}tjtdd}d|_tjtdd}d|_tjtd|d}d|_x`||g||gfD]L}||_|dd } |jt | |j tj||j tj||j tj|qjWdS) NcSs tddS)Nr0)r{rrrrr0szCPatchTest.test_patch_multiple_new_callable_failure..crasherr)rr*r-)rcSsdS)Nrrrrrr.sz@PatchTest.test_patch_multiple_new_callable_failure..func) r&r)r*r-rr#rrr8r{rC) rrrrr0rr2r3r4r.rrr(test_patch_multiple_new_callable_failures"  z2PatchTest.test_patch_multiple_new_callable_failurecs^xXttfD]L}td|fddi}|tjddfdd}|jjdq WdS)Nr&fishZtastyz nearly gone)r7csjjddS)Nz nearly gone)rCr7r)r-rrrrEsz=PatchTest.test_patch_multiple_string_subclasses..test)strunicoderrrrCr7)rbaser&rEr)r-rr%test_patch_multiple_string_subclassess z/PatchTest.test_patch_multiple_string_subclasseszmock.patch.TEST_PREFIXr-cCslGdddt}tj|dd|}|}|j|jd|j|jd|j|jd|j|jddS)Nc@s0eZdZdZddZddZddZdd Zd S) z-PatchTest.test_patch_test_prefix..FoorOcSs|jS)N)r)rrrrfoo_one#sz5PatchTest.test_patch_test_prefix..Foo.foo_onecSs|jS)N)r)rrrrfoo_two%sz5PatchTest.test_patch_test_prefix..Foo.foo_twocSs|jS)N)r)rrrrr'sz6PatchTest.test_patch_test_prefix..Foo.test_onecSs|jS)N)r)rrrrr)sz6PatchTest.test_patch_test_prefix..Foo.test_twoN)rrrrr<r=rrrrrrr& s r&rchangedrO)r#rrCr<r=rr)rr&r-rrrtest_patch_test_prefixs z PatchTest.test_patch_test_prefixr+csGfdddt}dditjdd|}|}|j|jddi|j|jddi|j|jddi|j|jddidS)Ncs<eZdZfddZfddZfddZfddZd S) z2PatchTest.test_patch_dict_test_prefix..FoocstS)N)r)r)the_dictrrbar_one8sz:PatchTest.test_patch_dict_test_prefix..Foo.bar_onecstS)N)r)r)r@rrbar_two:sz:PatchTest.test_patch_dict_test_prefix..Foo.bar_twocstS)N)r)r)r@rrr<sz;PatchTest.test_patch_dict_test_prefix..Foo.test_onecstS)N)r)r)r@rrr>sz;PatchTest.test_patch_dict_test_prefix..Foo.test_twoN)rrrrArBrrr)r@rrr&7s   r&keyrOr>)rC)r#rrrCrArBrr)rr&r-r)r@rtest_patch_dict_test_prefix5s z%PatchTest.test_patch_dict_test_prefixc Csxd D]x}tdtf|di}|j}zL|jdt||jdt|j|jdt||jd t|jWd|jXqWdS) Nrhrrz %s.SomeClassTz name='SomeClass'z! name='SomeClass.class_attribute'z name='SomeClass()'z# name='SomeClass().class_attribute')rhrr)rrrrrr]r)rrrrrrrtest_patch_with_spec_mock_reprKs  z(PatchTest.test_patch_with_spec_mock_reprc CsVtddd}|j}z2|jdt|jj|jdt|jjWd|jXdS)Nzmock.tests.supportT)rz" name='support.SomeClass.wibble()'z$ name='support.SomeClass().wibble()')rrrrrrkr)rrrrrrtest_patch_nested_autospec_reprZs z)PatchTest.test_patch_nested_autospec_reprc CsxdD]}tdtf|di}|j}z|jtjg}|j|j||j|j||j|jjtg|}|jt|j|j||j|jtj|j|j||j|jtjg|j|jjtg|j|jtjgWd|j XqWdS)Nrhrrz %s.SomeClassT)rhrr) rrrrkrrCZ mock_callsZ method_callsappendr)rrrrZkallsrrrrtest_mock_calls_with_patchfs&   z$PatchTest.test_mock_calls_with_patchcCsjtjjddtd}|jt|jt}d|_|tjd<td}d|_|j|j |j |jddS)Nsquizzz squizz.squozzr) rrr rr8 ImportErrorrr ZsquozzrrC)rp1rIrrrtest_patch_imports_lazilys z#PatchTest.test_patch_imports_lazilycsGdddGfdddtfdd}|ddd }|jt||jjd t|jjd d |jjd ddS)Nc@seZdZdZdS)z.holderN)NNN)rrrrrrrrholdersrNcseZdZdfdd ZeZdS)zBPatchTest.test_patch_propogrates_exc_on_exit..custom_patchNcs tj|||||||f_dS)N)r__exit__r)retypevaltb)rNrrrOszKPatchTest.test_patch_propogrates_exc_on_exit..custom_patch.__exit__)NNN)rrrrOrr)rNrr custom_patchsrSc s$t|\}}||tdddddi S)NF)rr )targetgetterr@)rSrrwith_custom_patchs  zGPatchTest.test_patch_propogrates_exc_on_exit..with_custom_patchz squizz.squozzcSstdS)N)r)r[rrrrEsz:PatchTest.test_patch_propogrates_exc_on_exit..testrrzexception value not propgatedrz!exception traceback not propgated)rr8rrrZassertIsNotNone)rrVrEr)rSrNr"test_patch_propogrates_exc_on_exits    z,PatchTest.test_patch_propogrates_exc_on_exitcCstxnd D]f}tdtfddi|di}|jt|j|jtddttfddi|di}|j|jqWdS) Nrhrrz%s.doesnotexistrxTcSstS)N) doesnotexistrrrrrjsz1PatchTest.test_create_and_specs..)rhrr)rrr8r9rr{MODNAMEr)rkwargrrrrtest_create_and_specss  zPatchTest.test_create_and_specscCst}x>dD]6}ttfddi|di}|jt|j|jt|q Wx>dD]6}ttfddi|di}|jt|j|jt|qJWx>dD]6}ttfddi|di}|jt|j|jt|qWdS)Nrhrrr)rhr)rhr)rr)rQrrYr8r9rr)rrOrZrrrrtest_multiple_specss   zPatchTest.test_multiple_specsc Cs8ttdddd}|j}z|jd|_Wd|jXdS)NF)rhrrr)rrYrZdoes_not_existr)rrr[rrr test_specs_false_instead_of_nones  z*PatchTest.test_specs_false_instead_of_nonec CsJxDdD]<}ttf|di}|j}z|jtt|dWd|jXqWdS)NrhrrrZ doesnotexit)rhrr)rrYrr8rlrr)rrZrrrrrtest_falsey_specs  zPatchTest.test_falsey_specc Csdx^dD]V}ttfddi|di}|j}z&|jtt|dd|jtt|dWd|jXqWdS)NrhrrTrXrM)rhr)rrYrr8rlrrr)rrZrrrrrtest_spec_set_trues  zPatchTest.test_spec_set_truec Cs:d}tt|d}|j}z|jt|Wd|jXdS)N__call__)rh)r`)rrYrr:rr)rrhrrrrrtest_callable_spec_as_lists  z$PatchTest.test_callable_spec_as_listc Cs:d}tt|d}|j}z|jt|Wd|jXdS)Nr-r+)rh)r-r+)rrYrr;rr)rrhrrrrrtest_not_callable_spec_as_lists  z(PatchTest.test_not_callable_spec_as_listcs^tjtjtj}tdtjtdtjtdfdd}|jtj|dS)Nz os.unlinkzos.chdirzos.pathcs6tjjtj|jtjjtjdS)N)rstopallrrpathunlinkchdir)Z mock_path)rfrrerrpatched sz-PatchTest.test_patch_stopall..patched) rrerfrdrrMrrRr)rrdrgr)rfrrertest_patch_stopallszPatchTest.test_patch_stopallcCstdt}|j|jtdS)Nz sys.modules)rr/r __wrapped__)r decoratedrrrtest_wrapped_patchs zPatchTest.test_wrapped_patchcCs*tdt}td|}|j|jtdS)Nz sys.modules)rr/rri)rrjrrr test_wrapped_several_times_patchs  z*PatchTest.test_wrapped_several_times_patchcCs"tjtdt}|j|jtdS)Nr)rr#rr/rri)rrjrrrtest_wrapped_patch_objectsz#PatchTest.test_wrapped_patch_objectcCs tjdt}|j|jtdS)Nz sys.modules)rrr/rri)rrjrrrtest_wrapped_patch_dict$sz!PatchTest.test_wrapped_patch_dictcCs$tjdidt}|j|jtdS)Nr)r)rrr/rri)rrjrrrtest_wrapped_patch_multiple)sz%PatchTest.test_wrapped_patch_multiplecsRgGdddtfddfddd Dtj|jd ddgdS) Nc@seZdZdZZZdS)z*PatchTest.test_stopall_lifo..thingN)rrronetwothreerrrrr/src s8Gfdddtfddddddddi S)Ncs"eZdZfddZZS)z?PatchTest.test_stopall_lifo..get_patch..mypatchcsjt|jS)N)rGsuperr)r) __class__r@mypatchstoppedrrr4s zDPatchTest.test_stopall_lifo..get_patch..mypatch.stop)rrrr __classcell__r)r@rurv)rtrru3srucsS)Nrr)rrrrj7sz@PatchTest.test_stopall_lifo..get_patch..F)r)r@)rvr)r@rur get_patch2sz.PatchTest.test_stopall_lifo..get_patchcsg|]}|jqSr)r).0rQ)rxrr 9sz/PatchTest.test_stopall_lifo..rprqrr)rprqrr)r#rrcrC)rr)rxrvrrtest_stopall_lifo-s zPatchTest.test_stopall_lifoc&CsTddd}tj|dd|j|dWdQRX|j|dtj|dd|j|jdWdQRX|j|jdtj|d d |j|jd WdQRX|j|jtt|jd rtj|d tdg|j|j tdgWdQRX|j|j tt|jd rPt d}tj|d tdg|j|dWdQRX|j|ddS)NrcSs|S)TESTr)r rrrr-@sz)PatchTest.test_special_attrs..foo __defaults__r__doc__ZFUNr|rZ testpatch2__annotations__s__kwdefaults__zlambda *a, x=0: xr )r)r)rr)rr)r r) rr#rCr~rrr}test_special_attrsrreval)rr-rrrr?s& zPatchTest.test_special_attrsN)T)lrrrr>rFrHrLrPr\r_rgrnrprqrrrsrtrurwr|r~rrrrrrrrrrrrrrrrrZexpectedFailurerrrrrrrrrrrrrrrrrrrrrrrrrrrrr r rrrrrr!r#r$r&r'r)r/r1r5r6r;rr?rDrErFrHrMrWr[r\r]r^r_rarbrhrkrlrmrnror{rrrrrr7Ws   + *          ! +     G         +!!        r7__main__)T)-rrsixZ unittest2rZ mock.testsrZmock.tests.supportrrrr[rrrr r r r r rZ mock.mockrrrYPY3r8r9rrrQrYr%rArMrSrRr#r&rr/r0ZTestCaser7mainrrrrsJ 0