Viewing File: /opt/alt/python35/lib/python3.5/site-packages/mock/tests/__pycache__/testpatch.cpython-35.pyc



/V@sddlZddlZddlZddlZddlmZddlmZm	Z	m
Z
ddlmZm
Z
mZmZmZmZmZmZmZmZddlmZmZdZejrdZeZejeZdeZd	d
dZ ej!a"ej#Z$Gdd
d
e%Z&deZ'e&ddZ(Gddde%Z)Gdddej*Z+edkrej,dS)N)support)	SomeClassis_instancecallable)
NonCallableMock
CallableMixinpatchsentinel	MagicMockMockNonCallableMagicMockrDEFAULTcall)_patch_get_target__builtin__builtinsz%s.PTModuleTcs_Gfdddt}|sXfdd}fdd}||_||_|S)Ncs"eZdZfddZdS)z_get_proxy.<locals>.Proxycs
t|S)N)getattr)selfname)obj
/testpatch.py__getattr__ sz%_get_proxy.<locals>.Proxy.__getattr__N)__name__
__module____qualname__rr)rrrProxysrcst||dS)N)setattr)rrvalue)rrr__setattr__#sz_get_proxy.<locals>.__setattr__cst|dS)N)delattr)rr)rrr__delattr__%sz_get_proxy.<locals>.__delattr__)objectr r")rget_onlyrr r"r)rr
_get_proxys		r%c@sPeZdZddZddZddZdZGdd	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:sr,N)	rrrr(r)r*foor#r,rrrrr&1s
r&z%s.FoocCsdS)Nr)r'brrrfunctionAsr/c@sLeZdZddZddZddZddZd	d
ZdS)	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@seZdZdddZddZddZdd	Zd
dZdd
ZddZ	ddZ
ddZddZddZ
ddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Zd<d=Z d>d?Z!d@dAZ"dBdCZ#dDdEZ$e%j&dFdGZ'dHdIZ(dJdKZ)dLdMZ*dNdOZ+dPdQZ,dRdSZ-dTdUZ.dVdWZ/dXdYZ0dZd[Z1d\d]Z2d^d_Z3d`daZ4dbdcZ5dddeZ6dfdgZ7dhdiZ8djdkZ9dldmZ:dndoZ;dpdqZ<drdsZ=dtduZ>dvdwZ?dxdyZ@dzd{ZAd|d}ZBd~dZCddZDddZEddZFddZGddZHddZIddZJddZKddZLddZMddZNddZOddZPddZQddZRddZSddZTeUddddZVeUddddZWddZXddZYddZZddZ[ddZ\ddZ]ddZ^ddZ_ddZ`ddZaddZbddZcddZdddZeddZfddZgddZhddZiddZjddZkdS)	PatchTestTcCsRt}|st}|jt||jt|||jt|tdS)N)rrassertRaises	TypeError
assertTruerassertFalser)rrmagic	MockClassrrrassertNotCallableYszPatchTest.assertNotCallablecsgGdddttjdtjfdd}|jjtjddS)Nc@seZdZejZdS)z4PatchTest.test_single_patchobject.<locals>.SomethingN)rrrr	Original	attributerrrr	SomethingdsrAr@csjjtjddS)N	unpatched)assertEqualr@r	Patchedr)rArrrtestgsz/PatchTest.test_single_patchobject.<locals>.testzpatch not restored)r#rr	rDrCr@r?)rrEr)rArrtest_single_patchobjectcs
-z!PatchTest.test_single_patchobjectcsdGdddttjddfdd}|jjtjddS)Nc@seZdZejZdS)z7PatchTest.test_patchobject_with_none.<locals>.SomethingN)rrrr	r?r@rrrrrAqsrAr@csjjddS)NrB)assertIsNoner@r)rArrrrEtsz2PatchTest.test_patchobject_with_none.<locals>.testzpatch not restored)r#rrCr@r	r?)rrEr)rArrtest_patchobject_with_noneps
*z$PatchTest.test_patchobject_with_nonecsGdddttjdtjtjdtjfdd}|jjtjdjjtj	ddS)Nc@s"eZdZejZejZdS)z6PatchTest.test_multiple_patchobject.<locals>.SomethingN)rrrr	r?r@	Original2next_attributerrrrrA~s	rAr@rJcs6jjtjdjjtjddS)NrB)rCr@r	rDrJPatched2r)rArrrrEsz1PatchTest.test_multiple_patchobject.<locals>.testzpatch not restored)
r#rr	rDrKrCr@r?rJrI)rrEr)rArrtest_multiple_patchobject}s0z#PatchTest.test_multiple_patchobjectc
Cs]t}tdttjdd}z'tja||jttjWd|aXdS)Nz%s.somethingcSsdS)NrrrrrrEsz8PatchTest.test_object_lookup_is_quite_lazy.<locals>.test)	somethingrrr	
Something2Zreplacement_valuerC)roriginalrErrr test_object_lookup_is_quite_lazys"	z*PatchTest.test_object_lookup_is_quite_lazycsPtdttjfdd}|jtjtjdtdttjtdttjfdd}jtjtjdjtj	tjd|jtjtjdjtj	tjdt
}tj|_tdt
|fdd}||jt|ddS)	Nz%s.somethingcsjtjtjddS)NrB)rCPTModulerMr	rNr)rrrrEsz"PatchTest.test_patch.<locals>.testzpatch not restoredz%s.something_elsecs6jtjtjdjtjtjddS)NrB)rCrQrMr	rNsomething_else
SomethingElser)rrrrEsz%s.opencs#jtddtjddS)Nfilenamerzopen not patched)rCopenr	Handler)rrrrEs)rrr	rNrCrQrMrArSrRrrWreturn_valuebuiltin_stringassertNotEqualrV)rrEmockr)rr
test_patchs*(+	%zPatchTest.test_patchcsItdttjfdd}|jtjjddS)Nz%s.SomeClass.class_attributecs jtjjtjddS)NrB)rCrQrclass_attributer	ClassAttributer)rrrrEsz2PatchTest.test_patch_class_attribute.<locals>.testzpatch not restored)rrr	r^rGrQrr])rrEr)rrtest_patch_class_attributes

z$PatchTest.test_patch_class_attributecsGdddttjdfdd}|tjdtjdfdd}d|tjtj\|tjtjdS)Nc@s"eZdZejZejZdS)z:PatchTest.test_patchobject_with_default_mock.<locals>.TestN)rrrr	r?rMrI
something2rrrrTests	rarMcs-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.<locals>.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'0
z,PatchTest.test_patchobject_with_default_mockcs3tdtdtfdd}|dS)Nz%s.SomeClassspeccsCjt|jttjtjtdddS)NcSstjS)N)r
not_wibblerrrr<lambda>sz>PatchTest.test_patch_with_spec.<locals>.test.<locals>.<lambda>)rCrr:rwibbler
r8AttributeError)
MockSomeClass)rrrrEsz,PatchTest.test_patch_with_spec.<locals>.test)rrr)rrEr)rrtest_patch_with_specs(zPatchTest.test_patch_with_speccs5tjtddtfdd}|dS)Nr]rhcsIjtj|jttjjtjtdddS)NcSs
tjjS)N)rr]rirrrrrjszDPatchTest.test_patchobject_with_spec.<locals>.test.<locals>.<lambda>)	rCrr]r:rrkr
r8rl)
MockAttribute)rrrrEs

	z2PatchTest.test_patchobject_with_spec.<locals>.test)rr#r)rrEr)rrtest_patchobject_with_specs*z$PatchTest.test_patchobject_with_speccs6tdtddgfdd}|dS)Nz%s.SomeClassrhrkcsCjt|jttjtjtdddS)NcSstjS)N)rrirrrrrjszFPatchTest.test_patch_with_spec_as_list.<locals>.test.<locals>.<lambda>)rCrr:rrkr
r8rl)rm)rrrrEsz4PatchTest.test_patch_with_spec_as_list.<locals>.test)rr)rrEr)rrtest_patch_with_spec_as_lists+z&PatchTest.test_patch_with_spec_as_listcs8tjtdddgfdd}|dS)Nr]rhrkcsIjtj|jttjjtjtdddS)NcSs
tjjS)N)rr]rirrrrrj(szLPatchTest.test_patchobject_with_spec_as_list.<locals>.test.<locals>.<lambda>)	rCrr]r:rrkr
r8rl)ro)rrrrE"s

	z:PatchTest.test_patchobject_with_spec_as_list.<locals>.test)rr#r)rrEr)rr"test_patchobject_with_spec_as_list!s-z,PatchTest.test_patchobject_with_spec_as_listcsFtdttdtddgfdd}|dS)Nz%s.openz%s.SomeClassrhrkcsCjt|jttjtjtdddS)NcSstjS)N)rrirrrrrj4szMPatchTest.test_nested_patch_with_spec_as_list.<locals>.test.<locals>.<lambda>)rCrr:rrkr
r8rl)rmZMockOpen)rrrrE/sz;PatchTest.test_nested_patch_with_spec_as_list.<locals>.test)rrYr)rrEr)rr#test_nested_patch_with_spec_as_list-s
.z-PatchTest.test_nested_patch_with_spec_as_listcs3tdtddfdd}|dS)Nz%s.SomeClassrhTcs7jtjjtfdddS)NcsjS)N)rir)rmrrrj?szIPatchTest.test_patch_with_spec_as_boolean.<locals>.test.<locals>.<lambda>)rCrrkr8rl)rm)r)rmrrE9sz7PatchTest.test_patch_with_spec_as_boolean.<locals>.test)rr)rrEr)rrtest_patch_with_spec_as_boolean8s(z)PatchTest.test_patch_with_spec_as_booleancs5tjtdddfdd}|dS)NrrhTcs7jtjjtfdddS)NcsjS)N)rir)rmrrrjKszPPatchTest.test_patch_object_with_spec_as_boolean.<locals>.test.<locals>.<lambda>)rCrrkr8rl)rm)r)rmrrEEsz>PatchTest.test_patch_object_with_spec_as_boolean.<locals>.test)rr#rQ)rrEr)rr&test_patch_object_with_spec_as_booleanDs*z0PatchTest.test_patch_object_with_spec_as_booleancs3tdtddfdd}|dS)Nz%s.SomeClassrhTcsSjt|t|jjjtfdddS)NcsjS)N)rir)instancerrrjYszVPatchTest.test_patch_class_acts_with_spec_is_inherited.<locals>.test.<locals>.<lambda>)r:rr
r>rkr8rl)rm)r)rvrrEQs
	
zDPatchTest.test_patch_class_acts_with_spec_is_inherited.<locals>.test)rr)rrEr)rr,test_patch_class_acts_with_spec_is_inheritedPs(
z6PatchTest.test_patch_class_acts_with_spec_is_inheritedcsOtdttjddfdd}|jtdddS)Nz
%s.frooblecreateTcsjttjdS)N)rCfroobler	Froobler)rrrrE_szLPatchTest.test_patch_with_create_mocks_non_existent_attributes.<locals>.testcSstS)N)ryrrrrrjdszPPatchTest.test_patch_with_create_mocks_non_existent_attributes.<locals>.<lambda>)rrYr	rzr8	NameError)rrEr)rr4test_patch_with_create_mocks_non_existent_attributes^s.z>PatchTest.test_patch_with_create_mocks_non_existent_attributescsQtjtdtjddfdd}|jttddS)NryrxTcsjtjtjdS)N)rCrryr	rzr)rrrrEhszRPatchTest.test_patchobject_with_create_mocks_non_existent_attributes.<locals>.test)rr#rr	rzr;hasattr)rrEr)rr:test_patchobject_with_create_mocks_non_existent_attributesgs0zDPatchTest.test_patchobject_with_create_mocks_non_existent_attributescsoy3tdttjfdd}|Wntk
rGYnXjdjtdddS)Nz
%s.frooblecsjttjdS)N)rCryr	rzr)rrrrErsz9PatchTest.test_patch_wont_create_by_default.<locals>.testz,Patching non existent attributes should failcSstS)N)ryrrrrrj|sz=PatchTest.test_patch_wont_create_by_default.<locals>.<lambda>)rrYr	rzrlfailr8r{)rrEr)rr!test_patch_wont_create_by_defaultps(

z+PatchTest.test_patch_wont_create_by_defaultcsqy5tjtdtjfdd}|Wntk
rIYnXjdjttddS)NordcsjddS)Nz,Patching non existent attributes should fail)rr)rrrrEsz?PatchTest.test_patchobject_wont_create_by_default.<locals>.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_defaultcCsbttddd}ttddd}|j|d|j|ddS)	Nz.ordcSsd|_tdS)Nec)rXr)Zmock_ordrrrtest_ords	z>PatchTest.test_patch_builtins_without_create.<locals>.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.<locals>.test_openrr)rrrC)rrrrrr"test_patch_builtins_without_creates
z,PatchTest.test_patch_builtins_without_createcspGdddttjdtddfdd}|jjtjdS)Nc@s"eZdZeddZdS)z5PatchTest.test_patch_with_static_methods.<locals>.FoocSstjS)N)r	Staticrrrrwootsz:PatchTest.test_patch_with_static_methods.<locals>.Foo.wootN)rrrstaticmethodrrrrrr&sr&rcSstjS)N)r	rDrrrrrjsz:PatchTest.test_patch_with_static_methods.<locals>.<lambda>csjjtjdS)N)rCrr	rDr)r&rrr	anonymoussz;PatchTest.test_patch_with_static_methods.<locals>.anonymous)r#rrrCrr	r)rrr)r&rrtest_patch_with_static_methodss6z(PatchTest.test_patch_with_static_methodscsNtj}tjtddfdd}|jtj|dS)Nr&csjtjddS)Nr&)rCr	r&r)rrrrsz-PatchTest.test_patch_local.<locals>.anonymous)r	r&rr#rC)rr-rr)rrtest_patch_locals	'zPatchTest.test_patch_localcsvGdddt}|tj_tjddfdd}|jjtjdS)Nc@seZdZdZdS)z'PatchTest.test_patch_slots.<locals>.Foor&N)zFoo)rrr	__slots__rrrrr&sr&csjjddS)Nr&)rCr&r)r-rrrrsz-PatchTest.test_patch_slots.<locals>.anonymous)r#r	r&rrC)rr&rr)r-rrtest_patch_slotss	*zPatchTest.test_patch_slotscsGdddtGfdddt}tjdtj|}|}|j|jjjtjddS)Nc@seZdZejZdS)z=PatchTest.test_patchobject_class_decorator.<locals>.SomethingN)rrrr	r?r@rrrrrAsrAcs:eZdZfddZfddZdS)z7PatchTest.test_patchobject_class_decorator.<locals>.FoocsjjtjddS)NrB)rCr@r	rD)
other_self)rArrrtest_methodszCPatchTest.test_patchobject_class_decorator.<locals>.Foo.test_methodcsjjtjddS)Nznon-test method patched)rCr@r	r?)r)rArrrnot_test_methodszGPatchTest.test_patchobject_class_decorator.<locals>.Foo.not_test_methodN)rrrrrr)rArrrr&sr&r@zpatch not restored)	r#rr	rDrrrCr@r?)rr&r)r)rArr test_patchobject_class_decorators	

z*PatchTest.test_patchobject_class_decoratorcsGdddt}Gfdddt}tdt|}|}|j|jj|jtjdjt	j
tjddS)Nc@seZdZejZdS)z7PatchTest.test_patch_class_decorator.<locals>.SomethingN)rrrr	r?r@rrrrrAsrAcs4eZdZfddZfddZdS)z1PatchTest.test_patch_class_decorator.<locals>.Foocsjtj|ddS)NrB)rCrQrM)rZmock_something)rrrrsz=PatchTest.test_patch_class_decorator.<locals>.Foo.test_methodcsjtjtjddS)Nznon-test method patched)rCrQrMr	rA)r)rrrrszAPatchTest.test_patch_class_decorator.<locals>.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_decoratorcsGdddttjdtjtjdtjfdd}|jjtjddS)Nc@s"eZdZejZejZdS)z3PatchTest.test_patchobject_twice.<locals>.SomethingN)rrrr	r?r@rIrJrrrrrAs	rAr@csjjtjddS)NrB)rCr@r	rDr)rArrrrEsz.PatchTest.test_patchobject_twice.<locals>.testzpatch not restored)r#rr	rDrCr@r?)rrEr)rArrtest_patchobject_twices0z PatchTest.test_patchobject_twicecsdtddij}tjfdd}|j|tjddifdd}|j|tjd
gfd	d}|j|dS)NinitialotherrMcsdd<d=dd<dS)Nr'rzsomething elserrr)r-rrrE	s
z'PatchTest.test_patch_dict.<locals>.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-s
z=PatchTest.test_patch_dict_with_container_object.<locals>.testr'r.cs1jtjdjdddS)Nrr'r.)rCrr1r)r-rrrrE7s)r0r#r1rrrrC)rrOrEr)r-rr%test_patch_dict_with_container_object&s	

!-z/PatchTest.test_patch_dict_with_container_objectcsdtddij}tjddfdd}|j|tjdd	iddfd
d}|j|tjdgddfdd}|j|dS)
NrrrMclearTcs(jidd<dd<dS)Nrr'zsomething elser)rCr)r-rrrrEEs
z2PatchTest.test_patch_dict_with_clear.<locals>.testr'r.csjddidS)Nr'r.)rCr)r-rrrrEOscsjddidS)Nr'r.)rCr)r-rrrrEWs)r'r.)r#rrrrC)rrOrEr)r-rrtest_patch_dict_with_clearAs*30z$PatchTest.test_patch_dict_with_clearcsttd<dd<jj}tjddfdd}|jj|tjdd	iddfd
d}|jj|dS)NrrMrrTcs+jjidd<dd<dS)Nrr'zsomething elser)rCr1r)r-rrrrEgs
zGPatchTest.test_patch_dict_with_container_object_and_clear.<locals>.testr'r.csjjddidS)Nr'r.)rCr1r)r-rrrrEqs)r0r#r1rrrrC)rrOrEr)r-rr/test_patch_dict_with_container_object_and_clear`s	

*3z9PatchTest.test_patch_dict_with_container_object_and_clearcCsi}tdtttdttddtjtttj|dd}|j|jddS)Nz%s.SomeClassautospecTcSsdS)Nrrrrr	some_name}sz0PatchTest.test_name_preserved.<locals>.some_namer)rrr#rrrC)rr-rrrrtest_name_preservedzs$zPatchTest.test_name_preservedcCski}tj|ddidd}y|Wntk
rIYnX|jd|j|idS)Nr'r.cSstddS)NZKonrad)r{rrrrrEsz1PatchTest.test_patch_with_exception.<locals>.testzNameError not raised by test)rrr{rrC)rr-rErrrtest_patch_with_exceptions$

z#PatchTest.test_patch_with_exceptioncs5tjdddifdd}|dS)Nz
os.environ
konrad_delongz
some valuecsjdtjdS)Nr)assertInosenvironr)rrrrEsz3PatchTest.test_patch_dict_with_string.<locals>.test)rr)rrEr)rrtest_patch_dict_with_strings*z%PatchTest.test_patch_dict_with_stringcsGdddtGfdddtjjddjjjddj}j|jdd|jj|jdd|jdS)Nc@seZdZdZdS)z0PatchTest.test_patch_descriptor.<locals>.NothingN)rrrr-rrrrNothingsrcseZdZiZejddefddZejddeddZ	ej
eefddZej
eed	d
ZdS)z2PatchTest.test_patch_descriptor.<locals>.Somethingr-csj|dS)N)assertIs)cls)rArrrklasssz8PatchTest.test_patch_descriptor.<locals>.Something.klasscSs|S)Nr)argrrrstaticsz9PatchTest.test_patch_descriptor.<locals>.Something.staticcsj|dS)N)r)r)rArrr
klass_dictsz=PatchTest.test_patch_descriptor.<locals>.Something.klass_dictcSs|S)Nr)rrrrstatic_dictsz>PatchTest.test_patch_descriptor.<locals>.Something.static_dictN)
rrrr-rr#classmethodrrrrrrr)rrArrrrAsrAZf00)r#rCrrrr)rrMr)rrArrtest_patch_descriptors"

	
zPatchTest.test_patch_descriptorcCstdtdtdd}|jt|tjtddtdd}|jt|tdtdddd}|jt|tjtdddd	d}|jt|dS)
Nz%s.SomeClassspec_setcSs
d|_dS)Nr-)z)r=rrrrEsz+PatchTest.test_patch_spec_set.<locals>.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_setcCs6tdtdddd}|jt|dS)Nz%s.SomeClassrTcSs|}d|_dS)Nr-)r)r=rvrrrrEs	z-PatchTest.test_spec_set_inherit.<locals>.test)rrr8rl)rrErrrtest_spec_set_inherits"zPatchTest.test_spec_set_inheritcCsxt}tdt}|jt||j}z$|j|||jt|Wd|jX|jt|dS)Nz%s.something)rMrrrstartassertIsNotstop)rrOpatcherr[rrrtest_patch_start_stopszPatchTest.test_patch_start_stopcCs)ttdd}|jt|jdS)Nr+r)rfoo_namer8RuntimeErrorr)rrrrrtest_stop_without_startsz!PatchTest.test_stop_without_startcCs}t}tjtdd}|jt||j}z$|j|d|jt|Wd|jX|jt|dS)NrMr-)rMrr#rQrrrCr)rrOrZreplacedrrrtest_patchobject_start_stopsz%PatchTest.test_patchobject_start_stopcCsddi}|j}tj|dgdd}|j|||jz|j|ddiWd|jX|j||dS)Nr-r+spameggsrT)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.<locals>.TestcsjddidS)Nr-r+)rC)r)rthisrr
test_first!szBPatchTest.test_patch_dict_class_decorator.<locals>.Test.test_firstcsjddidS)Nr-r+)rC)r)rrrrtest_second#szCPatchTest.test_patch_dict_class_decorator.<locals>.Test.test_secondN)rrrrrr)rrrrra srar-r+rT)rr#rrrCrr)rrOrarEr)rrrtest_patch_dict_class_decorators $	

	

z)PatchTest.test_patch_dict_class_decoratorcsGdddt}Gddd}x||||fD]|}t|tjddfdd}|jjdj|jdjdjq?WdS)	Nc@seZdZdZdS)z0PatchTest.test_get_only_proxy.<locals>.Somethingr-N)rrrr-rrrrrA;srAc@seZdZdZdS)z4PatchTest.test_get_only_proxy.<locals>.SomethingElser-N)rrrr-rrrrrS=srSr-r+csjjddS)Nr+)rCr-r)proxyrrrrECsz+PatchTest.test_get_only_proxy.<locals>.test)r#r%rrCr-assertNotIn__dict__)rrArSthingrEr)rrrtest_get_only_proxy:s*zPatchTest.test_get_only_proxycsGdddt}Gddd}x||||fD]}t|ddtjddfd	d
}|jjdj|jdjdjq?WdS)Nc@seZdZdZdS)z6PatchTest.test_get_set_delete_proxy.<locals>.Somethingr-N)rrrr-rrrrrAMsrAc@seZdZdZdS)z:PatchTest.test_get_set_delete_proxy.<locals>.SomethingElser-N)rrrr-rrrrrSOsrSr$Fr-r+csjjddS)Nr+)rCr-r)rrrrrEUsz1PatchTest.test_get_set_delete_proxy.<locals>.test)r#r%rrCr-rr)rrArSrrEr)rrrtest_get_set_delete_proxyLs*z#PatchTest.test_get_set_delete_proxycCsdtdddti}tt|}|j}|j|jt||j|jj	d|j
|jtdS)Nside_effectzfoo.bar.return_value!r-)KeyErrorr
rrrrr8rCr-r+rb)rkwargsrr[rrrtest_patch_keyword_args^s
z!PatchTest.test_patch_keyword_argscCsdtdddti}tjtd|}|j}|j|jt||j|j	j
d|j|j	tdS)Nrzfoo.bar.return_valuerr-r))rr
rr#r&rrr8rCr-r+rb)rrrr[rrrtest_patch_object_keyword_argsks
z(PatchTest.test_patch_object_keyword_argscCsddi}|j}tj|dddddd}|jz)|j|tddddddWd|jX|j||dS)Nr-r+rZbaz)rrrrrCr)rrOrrrrrtest_patch_dict_keyword_argsxs!
)z&PatchTest.test_patch_dict_keyword_argscsGdddt}fddfddfdd}ttd	d
|}|}jt||tjt}tj|dd	d
|}|}jt||dS)Nc@sPeZdZddZddZddZdZGdd	d	eZd
S)z$PatchTest.test_autospec.<locals>.BoocSsdS)Nr)rr'rrrr(sz-PatchTest.test_autospec.<locals>.Boo.__init__cSsdS)Nr)rr'rrrr)sz&PatchTest.test_autospec.<locals>.Boo.fcSsdS)Nr)rrrrr*sz&PatchTest.test_autospec.<locals>.Boo.gr+c@seZdZddZdS)z(PatchTest.test_autospec.<locals>.Boo.BarcSsdS)Nr)rrrrr'sz*PatchTest.test_autospec.<locals>.Boo.Bar.aN)rrrr'rrrrr,sr,N)	rrrr(r)r*r-r#r,rrrrBoos
rcs+|d|jdjt|dS)N)assert_called_withr8r9)r[)rrr_tests

z&PatchTest.test_autospec.<locals>._testcsn|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.<locals>._test2cs8|||dj|t|S)Nr)rr&)r[)rrrrrr/s


z)PatchTest.test_autospec.<locals>.functionrTr&)r#rrrr&sysmodulesr)rrr/rEr[moduler)rrrr
test_autospecs
	
	zPatchTest.test_autospeccs3tdtddfdd}|dS)Nz%s.functionrTcs^tdtjdtddtjddjttjtttddS)Nrrrr-)r/rr8r9rlr)r[)rrrrEs


z.PatchTest.test_autospec_function.<locals>.test)rr)rrEr)rrtest_autospec_functions(
z PatchTest.test_autospec_functioncCsEtdtdddddd}|}|j|ddS)Nz%s.functionrTrXrcSs
tddS)Nrr)r/)Z
mock_functionrrrrEsz.PatchTest.test_autospec_keywords.<locals>.test)rrrC)rrEresultrrrtest_autospec_keywordss	z PatchTest.test_autospec_keywordscCsqtdtdddd}|jt|jtjt}tj|ddddd}|jt|jdS)Nz%s.functionnewrrTr/)rrr8r9rrrr#)rrrrrrtest_autospec_with_news

z PatchTest.test_autospec_with_newc
CsmGdddt}ttd|}|j}z'|j|||j|jtWd|jXdS)Nc@seZdZgZdS)z0PatchTest.test_autospec_with_object.<locals>.BarN)rrrextrarrrrr,sr,r)r&rrrrbrlistr)rr,rr[rrrtest_autospec_with_objectsz#PatchTest.test_autospec_with_objectc
Cs`t}ttdd}|j}z*|j|||j|d|Wd|jXdS)NrTr)r&rrrrbr)rZFooClassrr[rrrtest_autospec_inheritssz PatchTest.test_autospec_inheritscCsttdd}|j}zn|jdt||jdt|j|jdt|d|jdt|djWd|jXdS)NrTz name='Foo'z
 name='Foo.f'z
 name='Foo()'z name='Foo().f')rrrrreprr)r)rrr[rrrtest_autospec_names#zPatchTest.test_autospec_namec
Cstjtdtdd}y|Wntj}YnXtjddd}|j||}|jd|dS)Nr)cSs
tdS)N)AssertionErrorrrrrrEsz'PatchTest.test_tracebacks.<locals>.testrzraise AssertionError)	rr#r&rexc_infounittestZTextTestResultZ_exc_info_to_stringr)rrEerrr	tracebackrrrtest_tracebackss$zPatchTest.test_tracebackscCsvttdt}|j}|j|j}|j|j||x!||fD]}|j|q[WdS)Nnew_callable)rrrrrrr>)rrm1m2r[rrrtest_new_callable_patch#s

z!PatchTest.test_new_callable_patchcCs|tjtddt}|j}|j|j}|j|j||x!||fD]}|j|qaWdS)Nr)r)rr#r&rrrrr>)rrrrr[rrrtest_new_callable_patch_object0s

z(PatchTest.test_new_callable_patch_objectc
sGfdddtttddddd}|j}z<|jt||jjtddddWd|j	XdS)Ncs(eZdZdZfddZdS)z:PatchTest.test_new_callable_keyword_arguments.<locals>.BarNcs
|_dS)N)r)rr)r,rrr(@szCPatchTest.test_new_callable_keyword_arguments.<locals>.Bar.__init__)rrrrr(r)r,rrr,>sr,rZarg1rZarg2r)
r#rrrrtyperCrrr)rrrr)r,r#test_new_callable_keyword_arguments=s&z-PatchTest.test_new_callable_keyword_argumentscsGfdddtttdd}|jz |jjtdWd|jXttdd}|jz |jjtdWd|jXdS)Ncs(eZdZdZfddZdS)z-PatchTest.test_new_callable_spec.<locals>.BarNcs
|_dS)N)r)rr)r,rrr(Osz6PatchTest.test_new_callable_spec.<locals>.Bar.__init__)rrrrr(r)r,rrr,Msr,rrhr)r#rrrrCrrr)rrr)r,rtest_new_callable_specLs
 
 z PatchTest.test_new_callable_specc
Cs|dt}t|dt}|jt|jt|dtdd}|j}z|j|ddWd|jXdS)Nz	%s.weeeeerrxTr<F)rrrr8rlrr>r)rZnon_existent_attrprrrrtest_new_callable_createas
	z"PatchTest.test_new_callable_createc	CsN|jtttdtdt|jttjtddtdtdS)Nrrr))r8
ValueErrorrrr#r
r&)rrrr'test_new_callable_incompatible_with_newos
z1PatchTest.test_new_callable_incompatible_with_newc	CsH|jtttdtdd|jttjtddtdddS)NrrTr))r8rrrr
r#r&)rrrr,test_new_callable_incompatible_with_autospecysz6PatchTest.test_new_callable_incompatible_with_autospecc	
CsGdddt}tttt|f}x}|D]u}xldD]d}|di}ttd||}|j}z#|j}|jt	t
|dWd|jXq?Wq2WdS)	Nc@seZdZdS)z>PatchTest.test_new_callable_inherit_for_mocks.<locals>.MockSubN)rrrrrrrMockSubsrrhrTrx)zspeczspec_set)rrrr
rrrrXr8rlrr)	rrZMockClassesZKlassrrrrrvrrr#test_new_callable_inherit_for_mockss

	z-PatchTest.test_new_callable_inherit_for_mockscCsGdddt}ttd|dd}|j}z0|jt|||jtt|dWd|j	X|j
|jtdS)Nc@seZdZddZdS)z>PatchTest.test_new_callable_inherit_non_mock.<locals>.NotAMockcSs
||_dS)N)rh)rrhrrrr(szGPatchTest.test_new_callable_inherit_non_mock.<locals>.NotAMock.__init__N)rrrr(rrrrNotAMocksr
rrhTrX)
r#rrrr:rr8rlrrrCrhr&)rr
rrrrr"test_new_callable_inherit_non_mocksz,PatchTest.test_new_callable_inherit_non_mockcsq|tGfdddt}ttdt|}|j|j|jtdS)Ncs=eZdZfddZddZddZdS)z>PatchTest.test_new_callable_class_decorating.<locals>.SomeTestcs4jtjt|jttdS)N)rr&rrbr)rmock_foo)rOrErrrszDPatchTest.test_new_callable_class_decorating.<locals>.SomeTest._testcSs|j|dS)N)r)rrrrrtest_twoszGPatchTest.test_new_callable_class_decorating.<locals>.SomeTest.test_twocSs|j|dS)N)r)rrrrrtest_oneszGPatchTest.test_new_callable_class_decorating.<locals>.SomeTest.test_oneN)rrrrr
rr)rOrErrSomeTestsrr)r&r#rrrrr
r)rrr)rOrEr"test_new_callable_class_decoratings

z,PatchTest.test_new_callable_class_decoratingcs(ttj}tj}tjtdddd}tjtdddd}x||fD]}|jz:jtjtjdjtjdWd|j	Xjtjtj|jtj|q[Wtjtddddfdd}|dS)	Nr)rr*rrrcs:jtjtjdjtjddS)Nrr)rr&rCr)r*r)original_foorrrrEsz+PatchTest.test_patch_multiple.<locals>.test)
r&r)r*rmultiplerrrrCr)r
original_f
original_gZpatcher1Zpatcher2rrEr)rrrtest_patch_multiples"		
0zPatchTest.test_patch_multiplecCs0|jttjt|jttjtdS)N)r8rrrrr&)rrrrtest_patch_multiple_no_kwargssz'PatchTest.test_patch_multiple_no_kwargscsttj}tj}tjtdtdddtfdd}|jtj|jtj|dS)Nr)r*rr-csyjtjtj|jtjdjtj|jt|tjt|tdS)Nr)	rr&r)rCr*r-r:rr
)r)r-)rrrrrEsz8PatchTest.test_patch_multiple_create_mocks.<locals>.test)r&r)r*rrrr
rC)rrrrEr)rrr test_patch_multiple_create_mockss		6	z*PatchTest.test_patch_multiple_create_mockscstj}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.<locals>.test)	r&r)r*rr#attribute_namer
additional_patchersrC)rrrrrrEr)rr0test_patch_multiple_create_mocks_different_orders				z:PatchTest.test_patch_multiple_create_mocks_different_ordercsPttj}tj}tjtdttjtdtttdfdd}tjtdtttdtjtdtfdd}ttdtjtdttjtdtfdd	}fd
d|||jtj|jtj|dS)Nr)r-z.gcs||dS)Nr)r*r)rrrtest1sz?PatchTest.test_patch_multiple_stacked_decorators.<locals>.test1cs||dS)Nr)r*r)rrrtest2sz?PatchTest.test_patch_multiple_stacked_decorators.<locals>.test2cs||dS)Nr)r*r)rrrtest3sz?PatchTest.test_patch_multiple_stacked_decorators.<locals>.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.<locals>._test)r&r)r*rrrr
rC)rrrrrrr)rrrr&test_patch_multiple_stacked_decorators	s$		(
-
-
z0PatchTest.test_patch_multiple_stacked_decoratorscCst}tj}tj}tjtdtdddt}|j}z|d}|d}|jt	|t	ddg|j
t||j
tj||j
tj||jt
|t|jt
|tWd|jX|jtj||jtj|dS)Nr)r*rr-)r&r)r*rrrr
rrCsetrr-r:rr
r)rrrrrrr)r-rrr(test_patch_multiple_create_mocks_patcher4s"		!

"z2PatchTest.test_patch_multiple_create_mocks_patchercs|ttj}tj}Gfdddt}tjtdtdddt|}|}|j|j	|j
tj||j
tj|dS)Ncs=eZdZfddZddZddZdS)z@PatchTest.test_patch_multiple_decorating_class.<locals>.SomeTestcsyjtjtj|jtjdjtj|jt|tjt|tdS)Nr)	rr&r)rCr*r-r:rr
)rr)r-)rrErrrUszFPatchTest.test_patch_multiple_decorating_class.<locals>.SomeTest._testcSs|j||dS)N)r)rr)r-rrrr
]szIPatchTest.test_patch_multiple_decorating_class.<locals>.SomeTest.test_twocSs|j||dS)N)r)rr)r-rrrr_szIPatchTest.test_patch_multiple_decorating_class.<locals>.SomeTest.test_oneN)rrrrr
rr)rrErrrSsrr)r*rr-)r&r)r*r#rrrr
rr
rC)rrrrrr)rrEr$test_patch_multiple_decorating_classMs				

z.PatchTest.test_patch_multiple_decorating_classcCstjtdd}|jt|jtjtdddd}|jz|jtjdWd|jX|j	t
tddS)NblamrxT)rrr&r8rlrrCr#rr;r})rrrrrtest_patch_multiple_createns
z$PatchTest.test_patch_multiple_createcCstjtdtdddg}|j}z}|jtj|dtjjdtjjdtjjj	dtjjj	d|j
tttjddWd|j
XdS)Nr-rr'r.rrr)rrr&r
rrCr-r'r.rr8rlrr)rrrrrrtest_patch_multiple_spec_set|s! z&PatchTest.test_patch_multiple_spec_setc
CsGdddt}tjtdtdtd|}|j}zn|jtj|d|jtj|d|j	tj||j	tj||j
tjtjWd|jXdS)Nc@seZdZdS)z9PatchTest.test_patch_multiple_new_callable.<locals>.ThingN)rrrrrrrThingsr&r)r*r)r#rrr&r
rrr)r*rbrr)rr&rrrrr test_patch_multiple_new_callablesz*PatchTest.test_patch_multiple_new_callablecCsGtj}tj}tjtddtjtddtjtdddd}tjtddtjtddtjtdddd}tjtddtjtddtjtddd	d
}xM|||fD]<}|jt||jtj||jtj|qWdS)Nr*rmissingr)cSsdS)Nrrrrrthing1sz3PatchTest.test_nested_patch_failure.<locals>.thing1cSsdS)Nrrrrrthing2sz3PatchTest.test_nested_patch_failure.<locals>.thing2cSsdS)Nrrrrrthing3sz3PatchTest.test_nested_patch_failure.<locals>.thing3)r&r)r*rr#r8rlrC)rrrr)r*r+funcrrrtest_nested_patch_failures		'''z#PatchTest.test_nested_patch_failurec	Csxtj}tj}tj}dd}tjtddtjtdd|tjtdddd	}tjtdd|tjtddtjtddd
d}tjtddtjtddtjtdd|dd
}x`|||fD]O}|jt||jtj||jtj||jtj|q!WdS)NcSstddS)Ncrasher)r{rrrrr.sz4PatchTest.test_new_callable_failure.<locals>.crasherr*rr-rr)cSsdS)Nrrrrrr)sz3PatchTest.test_new_callable_failure.<locals>.thing1cSsdS)Nrrrrrr*sz3PatchTest.test_new_callable_failure.<locals>.thing2cSsdS)Nrrrrrr+sz3PatchTest.test_new_callable_failure.<locals>.thing3)	r&r)r*r-rr#r8r{rC)	rrrrr.r)r*r+r,rrrtest_new_callable_failures$			''*z#PatchTest.test_new_callable_failurecCstj}tj}tjtdd}d|_tjtdd}d|_tjtdd}d|_xq||g||gfD]W}||_|dd}|jt||j	tj||j	tj|qWdS)Nr)rr*r(cSsdS)Nrrrrrr,sz3PatchTest.test_patch_multiple_failure.<locals>.func)
r&r)r*rr#rrr8rlrC)rrrrgoodbadadditionalsr,rrrtest_patch_multiple_failures						z%PatchTest.test_patch_multiple_failurec
Cstj}tj}tj}dd}tjtdd}d|_tjtdd}d|_tjtdd|}d|_x||g||gfD]j}||_|dd	}	|jt	|	|j
tj||j
tj||j
tj|qWdS)
NcSstddS)Nr.)r{rrrrr.szCPatchTest.test_patch_multiple_new_callable_failure.<locals>.crasherr)rr*r-rcSsdS)Nrrrrrr,sz@PatchTest.test_patch_multiple_new_callable_failure.<locals>.func)r&r)r*r-rr#rrr8r{rC)
rrrrr.rr0r1r2r,rrr(test_patch_multiple_new_callable_failures"							z2PatchTest.test_patch_multiple_new_callable_failurecsx|ttfD]n}td|fddi}|tjddfdd}|jjdq
WdS)Nr&fishZtastyznearly gonecsjjddS)Nznearly gone)rCr5r)r-rrrrEsz=PatchTest.test_patch_multiple_string_subclasses.<locals>.test)strunicoderrrrCr5)rbaser&rEr)r-rr%test_patch_multiple_string_subclassess	*z/PatchTest.test_patch_multiple_string_subclasseszmock.patch.TEST_PREFIXr-cCsGdddt}tj|dd|}|}|j|jd|j|jd|j|jd|j|jddS)Nc@sFeZdZdZddZddZddZdd	Zd
S)z-PatchTest.test_patch_test_prefix.<locals>.FoorOcSs|jS)N)r)rrrrfoo_one#sz5PatchTest.test_patch_test_prefix.<locals>.Foo.foo_onecSs|jS)N)r)rrrrfoo_two%sz5PatchTest.test_patch_test_prefix.<locals>.Foo.foo_twocSs|jS)N)r)rrrrr'sz6PatchTest.test_patch_test_prefix.<locals>.Foo.test_onecSs|jS)N)r)rrrrr
)sz6PatchTest.test_patch_test_prefix.<locals>.Foo.test_twoN)rrrrr:r;rr
rrrrr& 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)NcsXeZdZfddZfddZfddZfddZd	S)
z2PatchTest.test_patch_dict_test_prefix.<locals>.Foocs
tS)N)r)r)the_dictrrbar_one8sz:PatchTest.test_patch_dict_test_prefix.<locals>.Foo.bar_onecs
tS)N)r)r)r>rrbar_two:sz:PatchTest.test_patch_dict_test_prefix.<locals>.Foo.bar_twocs
tS)N)r)r)r>rrr<sz;PatchTest.test_patch_dict_test_prefix.<locals>.Foo.test_onecs
tS)N)r)r)r>rrr
>sz;PatchTest.test_patch_dict_test_prefix.<locals>.Foo.test_twoN)rrrr?r@rr
r)r>rrr&7sr&keyrOr<)r#rrrCr?r@rr
)rr&r-r)r>rtest_patch_dict_test_prefix5s
	z%PatchTest.test_patch_dict_test_prefixcCsxd
D]}tdt|di}|j}zh|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')zspeczautospeczspec_set)rrrrrr]r)rrrrrrrtest_patch_with_spec_mock_reprKs
		z(PatchTest.test_patch_with_spec_mock_reprc
Csutddd}|j}zE|jdt|jj|jdt|jjWd|jXdS)Nzmock.tests.supportrTz" name='support.SomeClass.wibble()'z$ name='support.SomeClass().wibble()')rrrrrrkr)rrrrrrtest_patch_nested_autospec_reprZs		z)PatchTest.test_patch_nested_autospec_reprcCsZxSdD]K}tdt|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)zspeczautospeczspec_set)
rrrrkrrCZ
mock_callsZmethod_callsappendr)rrrrZkallsrrrrtest_mock_calls_with_patchfs&

	
 z$PatchTest.test_mock_calls_with_patchcCstjjddtd}|jt|jt}d|_|tjd<td}d|_|j|j	|j
|jddS)Nsquizzz
squizz.squozzr)rrrrr8ImportErrorrrZsquozzrrC)rZp1rGrrrtest_patch_imports_lazilys		
	

z#PatchTest.test_patch_imports_lazilycsGdddGfdddtfdd}|ddd	}|jt||jjd
t|jjdd|jjd
ddS)Nc@seZdZdZdS)z<PatchTest.test_patch_propogrates_exc_on_exit.<locals>.holderN)NNN)rrrrrrrrholdersrKcs1eZdZdddfddZeZdS)zBPatchTest.test_patch_propogrates_exc_on_exit.<locals>.custom_patchNcs,tj|||||||f_dS)N)r__exit__r)retypevaltb)rKrrrLszKPatchTest.test_patch_propogrates_exc_on_exit.<locals>.custom_patch.__exit__)rrrrLrr)rKrrcustom_patchsrPc
s4t|\}}||tdddddi	S)NF)rr
)targetgetterr@)rPrrwith_custom_patchszGPatchTest.test_patch_propogrates_exc_on_exit.<locals>.with_custom_patchz
squizz.squozzcSs
tdS)N)r)r[rrrrEsz:PatchTest.test_patch_propogrates_exc_on_exit.<locals>.testrrzexception value not propgatedrz!exception traceback not propgated)rr8rrrZassertIsNotNone)rrSrEr)rPrKr"test_patch_propogrates_exc_on_exitsz,PatchTest.test_patch_propogrates_exc_on_exitcCsxd	D]}}tdtdd|di}|jt|j|jtddttdd|di}|j|jqWdS)
Nrhrrz%s.doesnotexistrxTcSstS)N)doesnotexistrrrrrjsz1PatchTest.test_create_and_specs.<locals>.<lambda>)zspeczspec_setzautospec)rrr8r9rr{MODNAMEr)rkwargrrrrtest_create_and_specss

zPatchTest.test_create_and_specscCst}xLdD]D}ttdd|di}|jt|j|jt|q
WxLdD]D}ttdd|di}|jt|j|jt|q\WxLdD]D}ttdd|di}|jt|j|jt|qWdS)Nrhrrr)specspec_set)rYr)rZr)rQrrVr8r9rr)rrOrWrrrrtest_multiple_specss


zPatchTest.test_multiple_specsc
CsPttdddddd}|j}z|jd|_Wd|jXdS)NrhFrrr)rrVrZdoes_not_existr)rrr[rrr test_specs_false_instead_of_nones
z*PatchTest.test_specs_false_instead_of_nonecCs^xWdD]O}tt|di}|j}z|jtt|dWd|jXqWdS)NrhrrrZdoesnotexit)zspeczautospeczspec_set)rrVrr8rlrr)rrWrrrrrtest_falsey_specs
zPatchTest.test_falsey_specc
Cs}xvdD]n}ttdd|di}|j}z3|jtt|dd|jtt|dWd|jXqWdS)NrhrrTrUrM)zspeczautospec)rrVrr8rlrrr)rrWrrrrrtest_spec_set_trues

zPatchTest.test_spec_set_truec
CsMd}ttd|}|j}z|jt|Wd|jXdS)N__call__rh)z__call__)rrVrr:rr)rrhrrrrrtest_callable_spec_as_listsz$PatchTest.test_callable_spec_as_listc
CsMd}ttd|}|j}z|jt|Wd|jXdS)Nr-r+rh)zfoozbar)rrVrr;rr)rrhrrrrrtest_not_callable_spec_as_listsz(PatchTest.test_not_callable_spec_as_listcstjtjtj}tdtjtdtjtdfdd}|jtj|dS)Nz	os.unlinkzos.chdirzos.pathcsGtjjtj|jtjjtjdS)N)rstopallrrpathunlinkchdir)Z	mock_path)rerrdrrpatched	s
z-PatchTest.test_patch_stopall.<locals>.patched)	rrdrercrrMrrRr)rrcrfr)rerrdrtest_patch_stopalls			$zPatchTest.test_patch_stopallcCs)tdt}|j|jtdS)Nzsys.modules)rr/r__wrapped__)r	decoratedrrrtest_wrapped_patchszPatchTest.test_wrapped_patchcCs;tdt}td|}|j|jtdS)Nzsys.modules)rr/rrh)rrirrr test_wrapped_several_times_patchsz*PatchTest.test_wrapped_several_times_patchcCs/tjtdt}|j|jtdS)Nr)rr#rr/rrh)rrirrrtest_wrapped_patch_objectsz#PatchTest.test_wrapped_patch_objectcCs,tjdt}|j|jtdS)Nzsys.modules)rrr/rrh)rrirrrtest_wrapped_patch_dict$sz!PatchTest.test_wrapped_patch_dictcCs2tjddit}|j|jtdS)Nrr)rrr/rrh)rrirrrtest_wrapped_patch_multiple)sz%PatchTest.test_wrapped_patch_multiplecsogGdddtfddfddd
Dtj|jd	ddgdS)Nc@seZdZdZZZdS)z*PatchTest.test_stopall_lifo.<locals>.thingN)rrronetwothreerrrrr/src
sPGfdddtfddddddddi	S)Ncs+eZdZfddZS)z?PatchTest.test_stopall_lifo.<locals>.get_patch.<locals>.mypatchcs jt|jS)N)rEsuperr)r)	__class__r@mypatchstoppedrrr4s
zDPatchTest.test_stopall_lifo.<locals>.get_patch.<locals>.mypatch.stop)rrrrr)r@rtru)rsrrt3srtcsS)Nrr)rrrrj7sz@PatchTest.test_stopall_lifo.<locals>.get_patch.<locals>.<lambda>F)r)r@)rur)r@rtr	get_patch2s"z.PatchTest.test_stopall_lifo.<locals>.get_patchcs"g|]}|jqSr)r).0rN)rvrr
<listcomp>9s	z/PatchTest.test_stopall_lifo.<locals>.<listcomp>rorprq)zoneztwozthree)r#rrbrC)rr)rvrurrtest_stopall_lifo-s
zPatchTest.test_stopall_lifoc&Csddd}tj|dd|j|dWdQRX|j|dtj|dd|j|jdWdQRX|j|jdtj|d	d
|j|jd
WdQRX|j|jtt|jdrBtj|dtdg!|j|j	tdgWdQRX|j|j	tt|jd
rt
d}tj|d
tdg|j|dWdQRX|j|ddS)NrcSs|S)TESTr)rrrrr-@sz)PatchTest.test_special_attrs.<locals>.foo__defaults__r__doc__ZFUNrzrZ
testpatch2__annotations__s__kwdefaults__zlambda *a, x=0: xr)r)r~r)r~r)rr)rr#rCr|rrr}test_special_attrsrr}eval)rr-rrrr?s&#zPatchTest.test_special_attrsN)lrrrr>rFrHrLrPr\r_rgrnrprqrrrsrtrurwr|r~rrrrrrrrrrrrrrrrrZexpectedFailurerrrrrrrrrrrrrrrrrrrrrrrrrrrrr	rrrrrrrr!r"r$r%r'r-r/r3r4r9rr=rBrCrDrFrJrTrXr[r\r]r^r`rargrjrkrlrmrnryrrrrrr7Ws


+*

		
!
+	



G	




+!!



r7__main__)-rrZsixZ	unittest2rZ
mock.testsrZmock.tests.supportrrrr[rrrr	r
rrr
rZ	mock.mockrrrYZPY3r6r7rrrQrVr%rArMrSrRr#r&rr/r0ZTestCaser7mainrrrr<module>s<F	

		


Back to Directory File Manager