a XC?hp@sddlZddlZddlZddlZddlmZmZmZmZm Z m Z m Z m Z m Z mZddlmZddlmZGdddeZGdddejZGd d d ejZGd d d ejZGd ddejZGdddejZedkredS)N) call_Callcreate_autospec MagicMockMockANY _CallListpatch PropertyMock _callable)datetimepartialc@s&eZdZddZddZdddZdS) SomeClasscCsdSNselfabrrG/opt/alt/python39/lib64/python3.9/unittest/test/testmock/testhelpers.pyonez SomeClass.onecCsdSrrrrrrtworz SomeClass.twoNcCsdSrrrrrrrthreerzSomeClass.three)N)__name__ __module__ __qualname__rrrrrrrrsrc@s<eZdZddZddZddZddZd d Zd d Zd S)AnyTestcCsF|ttt}|t|tt}|td|jtddSNfoo) assertEqualrobjectrassert_called_withrmockrrrtest_anys  zAnyTest.test_anycCs$|ttd|ttddS)Nz)r$reprrstrrrrr test_repr"szAnyTest.test_reprcCs,t}|ttd|jttddSr!)rr nowr&rr'rrrtest_any_and_datetime'szAnyTest.test_any_and_datetimecCst}Gdddt}t|fD]}|||||d|j|||d|j||dttttdtjtttdttjttdg}|||j ||j |q$dS)Nc@seZdZddZddZdS)z9AnyTest.test_any_mock_calls_comparison_order..FoocSsdSrrrotherrrr__eq__1rz@AnyTest.test_any_mock_calls_comparison_order..Foo.__eq__cSsdSrrr/rrr__ne__2rz@AnyTest.test_any_mock_calls_comparison_order..Foo.__ne__N)rrrr1r2rrrrFoo0sr3r#bar)ZzingaZalpha)Za1Zz99) rr%r r- reset_mockmethodrrr$ mock_calls)rr(r3dexpectedrrr$test_any_mock_calls_comparison_order.s z,AnyTest.test_any_mock_calls_comparison_ordercCsNGddd}t}||d|ttdg|td|tddS)Nc@seZdZddZdS)z%AnyTest.test_any_no_spec..FoocSsdSrrr/rrrr1Frz,AnyTest.test_any_no_spec..Foo.__eq__Nrrrr1rrrrr3Esr3rassert_has_callsrrr&assert_any_callrr3r(rrrtest_any_no_specCs   zAnyTest.test_any_no_speccCsRGddd}t|d}||d|ttdg|td|tddS)Nc@seZdZddZdS)z*AnyTest.test_any_and_spec_set..FoocSsdSrrr/rrrr1Qrz1AnyTest.test_any_and_spec_set..Foo.__eq__Nr<rrrrr3Psr3)specr=r>rArrrtest_any_and_spec_setNs    zAnyTest.test_any_and_spec_setN) rrrr)r,r.r;rBrDrrrrr s   r c@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+S),CallTestcCst}||t||td||td||tif||td||tdif||tddif||td||td||tdif||td diftd }||td ||td ||td if||tdd iftd }||td ||tdd iftd}||td||tddif||td||tddiftddif}||tddddif||tdddif||tdddif||tddifdS)N)r)rFrrFrr"r5rbazZspamr=)rFrKrK)r=rL)r#rN)rFrNrN)r5rNr5rrMrr$assertNotEqual)rkallrrrtest_call_with_call\s<zCallTest.test_call_with_callcCsjt}||d||d||d||d||ddif||dif||ifdS)Nrr"rGr#rr#)rr$rargsrrrtest_empty__Calls    zCallTest.test_empty__CallcCstddif}||d||d||ddif||dif||d||d||if||d||d||difdS) Nr#rr"rTrG)r5rHr5rPrUrrrtest_named_empty_calls      zCallTest.test_named_empty_callcCsftdif}||d||d||ddif||dif||jd||jidS)NrKrJr#rKr#)rr$rVkwargsrUrrrtest_call_with_argss   zCallTest.test_call_with_argscCshtddif}||d||ddif||jd||ji||d||difdS)Nr#rKrYrJ)rr$rVrZrQrUrrrtest_named_call_with_argss  z"CallTest.test_named_call_with_argsc Cstdtdddf}||tdddf||dtdddf||ddtdddf||dtdddf||jd||jtddddS)NrrMrOrrr#)rdictr$rVrZrUrrrtest_call_with_kwargsszCallTest.test_call_with_kwargsc Cstddtdddf}||dtdddf||ddtdddf||jd||jtddd||tdddf||dtdddfdS)Nr#rrMrOr])rr^r$rVrZrQrUrrrtest_named_call_with_kwargssz$CallTest.test_named_call_with_kwargscCsNtdif}||tddd|tddd||tddd|gdS)NrKr=rLrM)rr$rassertInrUrrr#test_call_with_args_call_empty_names z,CallTest.test_call_with_args_call_empty_namecCsR|tdtdd|tdtdddk|tdiftdddkdS)NrJr=rLrMr=rL)rQrr assertFalse assertTruerrrr test_call_neszCallTest.test_call_necCs8td}dd|tfD]}||||||kqdS)NrJr=)rintrQrd)rrRvaluerrrtest_call_non_tupless zCallTest.test_call_non_tuplescCs^|ttd|ttdd|ttdddifd|ttddddifd |ttd |ttd |ttd|ttd d |ttd dd|ttjd|ttd jjddjd|ttjd dddd|ttd|ttd dd|ttj d ddS)Nzcall()r"z call.foo()rKrrzcall(1, 2, 3, a='b')r5zcall.bar(1, 2, 3, a='b')rr=zcall(1)thing)Zzzzcall(zz='thing')z call().foorMrzcall().foo.bar().bingrLzcall().foo(1, 2, a=3)zcall()()z call()(2)zcall()().bar().baz.beep(1)) r$r*rrr+r#r5bingrIbeeprrrrr,s6zCallTest.test_reprcCs||tddif|tddddddddddft}|d d d|dd d ||jtd d dtdd d gdS) NrFrr#r5rMrO)rrr4r=rLr])r$rrcall_args_listr'rrr test_calls  zCallTest.test_callcCs|tdddif|tjjddddddift}|dd d |jjd d d ||jtdd d tjjd d d gdS) Nr=r#)r=Zeggs)fishzbar.bazrrqrLrMrnr])r$rr#r5rIr method_callsr'rrrtest_attribute_call s zCallTest.test_attribute_callc Cstddjddd}||ddtddft}|ddddd||jtddddd||jtddd||jtdddddg||j tdddddgt}|dj j d dtdj j d d}||j d |||j | dS) Nr=rLrMrOrkz ().foo().bar)rMr]rn) rr#r5r$r^rZ call_argsrQror8rIrm call_list)rresultr(Z last_callrrrtest_extended_callszCallTest.test_extended_callcCs@tddj}tddj}|||||||||dSNr=xrL)rr#r$rQrrrrtest_extended_not_equal*s     z CallTest.test_extended_not_equalcCsHtddj}tddj}|||||||||dSrx)rr#r5r$rQrrrrtest_nested_calls_not_equal2s   z$CallTest.test_nested_calls_not_equalcCst}|d|td|jt}|dd|tdd|jt}|ddd|tddd|jt}t|dddjj ddtdddjj dd }|||jdS)Nr=rLrMrO) rr$rrur8r7rgr#r5rI__int__)rr(rRrrrtest_call_list:s"$$zCallTest.test_call_listcCs>|ttt}t|||jtg|tg|jdSr)r$rrrrgr8rmrrr test_call_anyOs  zCallTest.test_call_anycCshtdddifdd}|t|d||dd||ddditdddif}|||dS) NrcrrMT)rrLrr=)rr$len)rrVZ other_argsrrrtest_two_args_callXs zCallTest.test_two_args_callcCsJ|tdddd|tddd|tdddifdddS) Nrr#r)r5ZbarzrFrZhelloZworld)r$rrrrrtest_call_with_nameaszCallTest.test_call_with_namec Cst}|d||jtttdtgt}d|d<||jtttddgt}t|||jtttgdS)Nr5r=) rr#r$r8r __getitem__ __setitem__iter__iter__rrrrtest_dunder_callfs$*zCallTest.test_dunder_callN)rrrrSrWrXr[r\r_r`rbrfrir,rprsrwr{r|rrrrrrrrrrEZs*%         rEc@s<eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMS)NSpecSignatureTestcCs|tt|d|dd|jdd|t|jjdd|t|jd||j|t|jjd|t|jd||j|t|jjd|t|jdd|d|jd|jdd|jjdddS)Nr#r=rLrMrOrk) assertRaisesAttributeErrorgetattrrr&AssertionError TypeErrorrrr'rrr_check_someclass_mock}s.       z'SpecSignatureTest._check_someclass_mockcCs*tt}||tt}||dSr)rrrr'rrr test_basics  zSpecSignatureTest.test_basiccCsPdd}t|dd}||dGdddt}t|dd}||ddS)NcSsdSrrrrrrfrz>SpecSignatureTest.test_create_autospec_return_value..fr# return_valuec@s eZdZdS)z@SpecSignatureTest.test_create_autospec_return_value..FooNrrrrrrrr3sr3)rr$r%)rrr(r3rrr!test_create_autospec_return_values   z3SpecSignatureTest.test_create_autospec_return_valuecCs,tt}t||||jjddS)Nr)rrgr6r$r~Z call_countrrrrtest_autospec_reset_mocksz*SpecSignatureTest.test_autospec_reset_mockcCs>Gdddt}t|d}|}|d|ddS)Nc@seZdZddZdS)z;SpecSignatureTest.test_mocking_unbound_methods..FoocSsdSrr)rr#rrrr#rz?SpecSignatureTest.test_mocking_unbound_methods..Foo.fooNrrrr#rrrrr3sr3r#r=)r%r startr#r&)rr3pZmock_foorrrtest_mocking_unbound_methodss   z.SpecSignatureTest.test_mocking_unbound_methodscCs.Gdddt}t|dd}||jddS)Nc@seZdZdZdS)zESpecSignatureTest.test_create_autospec_keyword_arguments..FoorMNrrrrrrrrr3sr33rk)r%rr$r)rr3rrrr&test_create_autospec_keyword_argumentss z8SpecSignatureTest.test_create_autospec_keyword_argumentscCsVdddd}t|}|d|d|t|dd|ddd|jddddS)NrcSsdSrrr]rrrr#rzJSpecSignatureTest.test_create_autospec_keyword_only_arguments..foor=rLrM)rr&rr)rr#rrrr+test_create_autospec_keyword_only_argumentss  z=SpecSignatureTest.test_create_autospec_keyword_only_argumentscCs6t}dd}||_t|}|d|jddS)NcSsdSrrrkrrrrrz@SpecSignatureTest.test_function_as_instance_attribute..frl)rrrr&)robjrr(rrr#test_function_as_instance_attributes  z5SpecSignatureTest.test_function_as_instance_attributecCsvtg}|d|jd|tt|dGdddt}t|}|jd|jjd|tt|jddS)Nr#c@seZdZgZdS)z0SpecSignatureTest.test_spec_as_list..FooNrrrrrr3sr3rM)rappendr&rrrr%r#)rr(r3rrrtest_spec_as_lists   z#SpecSignatureTest.test_spec_as_listcCs6Gdddt}t|}||jfD]}||q"dS)Nc@seZdZeZdS)z.SpecSignatureTest.test_attributes..SubNrrrrattrrrrrSubsr)rrrr)rrZsub_mockr(rrrtest_attributessz!SpecSignatureTest.test_attributescsGdddtGfdddt}t|}|d|t|Wdn1s^0Y|t|ddWdn1s0YdS)Nc@seZdZddZdS)zVSpecSignatureTest.test_spec_has_descriptor_returning_function..CrazyDescriptorcSs|durddSdS)NcSsdSrrryrrrrzpSpecSignatureTest.test_spec_has_descriptor_returning_function..CrazyDescriptor.__get__..r)rrtype_rrr__get__sz^SpecSignatureTest.test_spec_has_descriptor_returning_function..CrazyDescriptor.__get__NrrrrrrrrCrazyDescriptorsrcseZdZZdS)zNSpecSignatureTest.test_spec_has_descriptor_returning_function..MyClassN)rrr some_attrrrrrMyClasssrr=rL)r%rrrr)rrr(rrr+test_spec_has_descriptor_returning_functions  & z=SpecSignatureTest.test_spec_has_descriptor_returning_functioncsGfdddt}|t|jWdn1s@0Y||ddt|}|d|t|Wdn1s0Y|t|ddWdn1s0YdS)Ncs&eZdZfddZddZZS)zISpecSignatureTest.test_spec_has_function_not_in_bases..CrazyClasscst|dgS)Ncrazy)super__dir__r) CrazyClass __class__rrr szQSpecSignatureTest.test_spec_has_function_not_in_bases..CrazyClass.__dir__cSs|dkrddSt|dS)NrcSs|SrrryrrrrrzgSpecSignatureTest.test_spec_has_function_not_in_bases..CrazyClass.__getattr__..r)ritemrrr __getattr__szUSpecSignatureTest.test_spec_has_function_not_in_bases..CrazyClass.__getattr__)rrrrr __classcell__rr)rrr sr*r=rL)r%rrr0r$rrr)rinstr(rrr#test_spec_has_function_not_in_bases s  $  & z5SpecSignatureTest.test_spec_has_function_not_in_basescCsGdddt}t|}|d|jd|tt|jd|d|jd|t|jdd|tt|jd| ddg|j ddg|tt|j d|j d|j j d|tt|j ddS)Nc@seZdZddZeZiZdS)zGSpecSignatureTest.test_builtin_functions_types..BuiltinSubclasscSsdSrr)rargrrrr5'rzKSpecSignatureTest.test_builtin_functions_types..BuiltinSubclass.barN)rrrr5sortedrrrrrBuiltinSubclass&srrMr#r5r=rL) listrrr&rrrr5rrrpoprrr(rrrtest_builtin_functions_types"s     z.SpecSignatureTest.test_builtin_functions_typescCsGdddt}t|}|dd||dtddttdg}||j||jdd|j|jd| tjddtjtjdg||j|dS)Nc@seZdZeZdS)z0SpecSignatureTest.test_method_calls..SubNrrrrrr?srr=rLrM) rrrrrrr$rrrextend)rrr(r:rrrtest_method_calls>s     z#SpecSignatureTest.test_method_callscCs|Gdddt}t|}|t|g|tt||tt|j|t|g||dt||jdtdS)Nc@seZdZiZdS)z=SpecSignatureTest.test_magic_methods..BuiltinSubclassN)rrrrrrrrrUsrr#) rrr$rrrgrassertIsInstancerrrrrtest_magic_methodsTsz$SpecSignatureTest.test_magic_methodscCs`Gdddt}||fD]@}t|dd}|||tt|dd|tt|jddqdS)Nc@seZdZeZdS)z,SpecSignatureTest.test_spec_set..SubNrrrrrrcsrT)Zspec_setr#r5)rrrrrsetattrr)rrrCr(rrr test_spec_setbs   zSpecSignatureTest.test_spec_setcCsGdddt}Gddd|}Gdddt|}||||||fD]@}t|}|dd|jdd|d d |jd d qHdS) Nc@s$eZdZeddZeddZdS)z/SpecSignatureTest.test_descriptors..FoocSsdSrr)clsrrrrrrpsz1SpecSignatureTest.test_descriptors..Foo.fcSsdSrrr]rrrgrsz1SpecSignatureTest.test_descriptors..Foo.gN)rrr classmethodr staticmethodrrrrrr3os r3c@s eZdZdS)z/SpecSignatureTest.test_descriptors..BarNrrrrrBarurrc@s eZdZdS)z/SpecSignatureTest.test_descriptors..BazNrrrrrBazwrrr=rLrMrO)r%rrrassert_called_once_withr)rr3rrrCr(rrrtest_descriptorsns  z"SpecSignatureTest.test_descriptorscCsGdddt}||_t|}|||jj||j||jttjg| |j |j | |j |j |j |t|j j jdS)Nc@seZdZddZdZeZdS)z+SpecSignatureTest.test_recursive..AcSsdSrrrrrrrrz-SpecSignatureTest.test_recursive..A.az foo bar bazN)rrrrr#r5rrrrAsr)r%BrrdZcalledrr$rrrZassertIsr#r5 assertIsNotlowerrrr&)rrr(rrrtest_recursives  z SpecSignatureTest.test_recursivecCs^Gdddt}t|}|||||fD]L}|jdd|jjdd|jd|t|jdd|tt|dq0t|}|d|jd|jjdd|t|jdd|tt|d|t||j d|j j d|j j jdd |tt|j d | d| j d| j jdd |tt| d dS) Nc@s$eZdZddZGdddeZdS)z@SpecSignatureTest.test_spec_inheritance_for_classes..FoocSsdSrr)rrzrrrrrzBSpecSignatureTest.test_spec_inheritance_for_classes..Foo.ac@seZdZddZdS)zDSpecSignatureTest.test_spec_inheritance_for_classes..Foo.BarcSsdSrr)ryrrrrrzFSpecSignatureTest.test_spec_inheritance_for_classes..Foo.Bar.fNrrrrrrrrrsrN)rrrrr%rrrrrr3sr3r}ryr#r5rrn)rr) r%rrrr&rrrrrr)rr3Z class_mockZ this_mockZ instance_mockrrr!test_spec_inheritance_for_classess0       z3SpecSignatureTest.test_spec_inheritance_for_classescCsGdddt}||_t|}|}|tt|d|}|tt|dt|}|tt|d|t||}|tt|ddS)Nc@seZdZdZdS)z+SpecSignatureTest.test_inherit..FoorMNrrrrrr3sr3r)r%r3rrrrr)rr3r(instanceZ attr_instanceZ call_resultrrr test_inherits  zSpecSignatureTest.test_inheritcCstdtttdtttitttgtttttttdtttdtttdtddS)Nr=r#g?y?FT)rrgr+r^rsetfloatcomplexrrrr test_builtinss  zSpecSignatureTest.test_builtinscCsdd}t|}|t||dd|dd|jddd|jddd||_t|}|t|j|dd|jdd|jjddddS) NcSsdSrrr]rrrrrz*SpecSignatureTest.test_function..fr=rLrr]rMrO)rrrr&rrrr(rrr test_functions    zSpecSignatureTest.test_functioncsGdddtGfdddt}||dddt||tfdd |ddjj|tfd d j}|j |j fdS) Nc@seZdZdddZdS)z;SpecSignatureTest.test_skip_attributeerrors..RaiserNcSs|durtddS)Nz$Can only be accessed via an instancer)rrtyperrrrszCSpecSignatureTest.test_skip_attributeerrors..Raiser.__get__)NrrrrrRaisersrcseZdZZeddZdS)z@SpecSignatureTest.test_skip_attributeerrors..RaiserClasscSs||Srrr]rrrexistingszISpecSignatureTest.test_skip_attributeerrors..RaiserClass.existingN)rrrraiserrrr)rrr RaiserClasssrr=rLrMcsdddS)Nr=rLrM)rrysrrr rz=SpecSignatureTest.test_skip_attributeerrors..csjSr)Z nonexistingrrrrrr) r%r$rrrrrrrr#r5)rrrr)rrrtest_skip_attributeerrorssz+SpecSignatureTest.test_skip_attributeerrorscCsGdddt}t|}|t||d|d|jdd|t|jd|dd|dd|jddd|jt|jddddS) Nc@seZdZdddZdS)z3SpecSignatureTest.test_signature_class..FoorMcSsdSrrrrrr__init__rz.Foo.__init__N)rMrrrrrrrrr3sr3r=rkrLrOr}r])r%rrrrrr&rArrrtest_signature_classs     z&SpecSignatureTest.test_signature_classcCsGdddt}t|dS)Nc@s eZdZdS)z6SpecSignatureTest.test_class_with_no_init..FooNrrrrrr3*sr3)r%r)rr3rrrtest_class_with_no_init'sz)SpecSignatureTest.test_class_with_no_initcCsGdddt}t|}|dd|dd|jddd|t|d|dd}|t||dd|d|jdd|d|d|jddt|dd}|dd|jdd|t||d|ddS)Nc@seZdZddZddZdS)z;SpecSignatureTest.test_signature_callable..CallablecSsdSrr)rrzrrrrr1rzDSpecSignatureTest.test_signature_callable..Callable.__init__cSsdSrrrrrr__call__2rzDSpecSignatureTest.test_signature_callable..Callable.__call__N)rrrrrrrrrCallable0srr=rLrzrrrk)r%rrrrr&)rrr(rrrrtest_signature_callable/s(            z)SpecSignatureTest.test_signature_callablecCsvGdddt}t|}|}||t|d|t||t|dt|}|t||t|ddS)Nc@seZdZddZdS)zASpecSignatureTest.test_signature_noncallable..NonCallablecSsdSrrrrrrrMszJSpecSignatureTest.test_signature_noncallable..NonCallable.__init__Nrrrrr NonCallableLsrr)r%rrrr)rrr(rrrrtest_signature_noncallableKs   z,SpecSignatureTest.test_signature_noncallablecCsDGdddt}t|}|j}||td||jdS)Nc@seZdZdZdS)z8SpecSignatureTest.test_create_autospec_none..FooN)rrrr5rrrrr3]sr3)r%rr5assertNotIsInstancerr#r)rr3r(Znonerrrtest_create_autospec_none\s z+SpecSignatureTest.test_create_autospec_nonecCsfGdddt}t|}|d|jd|jjdd|jdd|jd|jjdddS)Nc@seZdZddZdS)zMSpecSignatureTest.test_autospec_functions_with_self_in_odd_place..FoocSsdSrr)rrrrrrjrzOSpecSignatureTest.test_autospec_functions_with_self_in_odd_place..Foo.fNrrrrrr3isr3 r)r%rrr&)rr3rrrr.test_autospec_functions_with_self_in_odd_placehs    z@SpecSignatureTest.test_autospec_functions_with_self_in_odd_placecsvGdddtGdddtGfdddt}t|}fdd}||j||j||j||jdS) Nc@s&eZdZddZdddZddZdS) zCSpecSignatureTest.test_autospec_data_descriptor..DescriptorcSs ||_dSr)rh)rrhrrrrwszLSpecSignatureTest.test_autospec_data_descriptor..Descriptor.__init__NcSs|Srr)rrrrrrrzszKSpecSignatureTest.test_autospec_data_descriptor..Descriptor.__get__cSsdSrr)rrrhrrr__set__}rzKSpecSignatureTest.test_autospec_data_descriptor..Descriptor.__set__)N)rrrrrrrrrr Descriptorvs rc@s eZdZdS)zCSpecSignatureTest.test_autospec_data_descriptor..MyPropertyNrrrrr MyPropertysrcs2eZdZdgZeddZddZdZdS)z.FooslotcSsdSrrrrrrpropszASpecSignatureTest.test_autospec_data_descriptor..Foo.propcSsdSrrrrrrsubpropszDSpecSignatureTest.test_autospec_data_descriptor..Foo.subproprN)rrr __slots__propertyrrdescr)rrrrr3s   r3csH|t|ddd|ddd|ddd|jddddS)Nr=rLrMrOr}rn)rrabcr)Z mock_attrrrrcheck_data_descriptors   zNSpecSignatureTest.test_autospec_data_descriptor..check_data_descriptor)r%rrrrrr)rr3r#rr)rrrrtest_autospec_data_descriptorus     z/SpecSignatureTest.test_autospec_data_descriptorcCs\ttjt}||tt|}||||ddd|ddddS)NrOr}rn) types MethodTypetimectimerr+rrr6)rZmethZmockedrrr'test_autospec_on_bound_builtin_functions z9SpecSignatureTest.test_autospec_on_bound_builtin_functioncCs0Gddd}|}t|}|t|ddS)Nc@seZdZddZdS)zESpecSignatureTest.test_autospec_getattr_partial_function..FoocSstdd|S)NcSs|Srr)namerrrrrzcSpecSignatureTest.test_autospec_getattr_partial_function..Foo.__getattr__..r )rZ attributerrrrszQSpecSignatureTest.test_autospec_getattr_partial_function..Foo.__getattr__N)rrrrrrrrr3sr3r)rrdhasattr)rr3proxyZautospecrrr&test_autospec_getattr_partial_functionsz8SpecSignatureTest.test_autospec_getattr_partial_functioncCspdd}t|}|dd|ddd|t|t|||jtddtdddg|t|ddS)NcSsdSrrrrrrmyfuncrz=SpecSignatureTest.test_spec_inspect_signature..myfuncr=rLr)rr$inspect signaturer8rrr)rrr(rrrtest_spec_inspect_signatures   z-SpecSignatureTest.test_spec_inspect_signaturecCsd ttttddd}||ddddd t|}|dddd|ddd|t|t|||jtddddtdddg|t|d|jt|dddd ddS) Nr)rrcreturncSs |||Srr)rrrrrrr#szFSpecSignatureTest.test_spec_inspect_signature_annotations..foor=rLrM)rrnrO)r) rgr$rrrr8rrr)rr#r(rrr'test_spec_inspect_signature_annotationss $z9SpecSignatureTest.test_spec_inspect_signature_annotationscCs"dd}t|}||jddS)NcSsdS)NZnoperrrrrrrz>SpecSignatureTest.test_spec_function_no_name..Zfuncopy)rr$r)rfuncr(rrrtest_spec_function_no_namesz,SpecSignatureTest.test_spec_function_no_namecCsfdd}t|}|d|tdg|t |tdgWdn1sX0YdS)NcSsdSrrrkrrrrrz@SpecSignatureTest.test_spec_function_assert_has_calls..fr=rL)rr?rrrrrrr#test_spec_function_assert_has_callss  z5SpecSignatureTest.test_spec_function_assert_has_callscCsZdd}t|}|d|d|t|dWdn1sL0YdS)NcSsdSrrrkrrrrrz?SpecSignatureTest.test_spec_function_assert_any_call..fr=rL)rr@rrrrrr"test_spec_function_assert_any_calls   z4SpecSignatureTest.test_spec_function_assert_any_callcCsvdd}t}t||d}|dd||jtdg||jtdg|||jg||jgdS)NcSsdSrrrkrrrrrz:SpecSignatureTest.test_spec_function_reset_mock..frr=rL)rrr$r8rr6)rrrvr(rrrtest_spec_function_reset_mocks  z/SpecSignatureTest.test_spec_function_reset_mockN))rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrr{sL      &  ,     rc@s,eZdZddZddZddZddZd S) TestCallListcCst}||jt|dd|dd|dd|ddtddtddtddtddfD]}|||jq`tddtddg}|||jtddtddg}|||jtddtddg}|||jtddg}|||j|td|j|tdg|jdS) Nr=rLrMrkrOrnrrq)rrrorrraZ assertNotIn)rr(rRZcallsrrr!test_args_list_contains_call_lists$    ( z.TestCallList.test_args_list_contains_call_listcCsJt}|dd|jdd|jjdddd}|t|j|dS) Nr=rLrMrkrqZdog)catzU[call(1, 2), call.foo(a=3), call.foo.bar(), call.foo.bar().baz('fish', cat='dog')])rr#r5rIr$r+r8)rr(r:rrrtest_call_list_strs  zTestCallList.test_call_list_strcCstdttd}|}zftj|t}|j|||j t t gd|_||j t t t dgW| n | 0dS)Nz%s.SomeClass.one)Z new_callablerM) r rr rrrrr&r$r8rstop)rrr(rrrrtest_propertymock&szTestCallList.test_propertymockcCs@t}t}|t|_|j}|||t||tdSr)rr rr#rrr)rrrZreturnedrrrtest_propertymock_returnvalue8s  z*TestCallList.test_propertymock_returnvalueN)rrrrr!r#r$rrrrrsrc@s<eZdZddZddZddZddZd d Zd d Zd S)TestCallablePredicatecCs(ttttttfD]}|t|qdSr)r+bytesrgrtuplerrer )rrrrr test_typeEszTestCallablePredicate.test_typecCs&Gddd}|}|t|dS)Nc@seZdZddZdS)z>TestCallablePredicate.test_call_magic_method..CallablecSsdSrrrrrrrKrzGTestCallablePredicate.test_call_magic_method..Callable.__call__N)rrrrrrrrrJsr)rer )rrrrrrtest_call_magic_methodIsz,TestCallablePredicate.test_call_magic_methodcCs"Gddd}|t|jdS)Nc@seZdZeddZdS)zATestCallablePredicate.test_staticmethod..WithStaticMethodcSsdSrrrrrr staticfuncQszLTestCallablePredicate.test_staticmethod..WithStaticMethod.staticfuncN)rrrrr*rrrrWithStaticMethodPsr+)rer r*)rr+rrrtest_staticmethodOsz'TestCallablePredicate.test_staticmethodcCs"Gddd}|t|jdS)Nc@seZdZedZdS)zMTestCallablePredicate.test_non_callable_staticmethod..BadStaticMethodN)rrrr not_callablerrrrBadStaticMethodVsr.rdr r-)rr.rrrtest_non_callable_staticmethodUsz4TestCallablePredicate.test_non_callable_staticmethodcCs"Gddd}|t|jdS)Nc@seZdZeddZdS)z?TestCallablePredicate.test_classmethod..WithClassMethodcSsdSrr)rrrr classfunc\szITestCallablePredicate.test_classmethod..WithClassMethod.classfuncN)rrrrr1rrrrWithClassMethod[sr2)rer r1)rr2rrrtest_classmethodZsz&TestCallablePredicate.test_classmethodcCs"Gddd}|t|jdS)Nc@seZdZedZdS)zKTestCallablePredicate.test_non_callable_classmethod..BadClassMethodN)rrrrr-rrrrBadClassMethodasr4r/)rr4rrrtest_non_callable_classmethod`sz3TestCallablePredicate.test_non_callable_classmethodN) rrrr(r)r,r0r3r5rrrrr%Cs r%__main__)rr rZunittestZ unittest.mockrrrrrrrr r r r functoolsrr%rZTestCaser rErrr%rmainrrrrs*0  E#G#