f _p@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) SomeClasscCsdSNselfabrr;/usr/lib64/python3.10/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)Zzingaalpha)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?rBrrrtest_any_and_spec_setNs    zAnyTest.test_any_and_spec_setN) rrrr)r,r.r<rCrErrrrr 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)rGrrGrr"r5rbazZspamr>)rGrLrL)r>rM)r#rO)rGrOrO)r5rOr5rrNrr$assertNotEqual)rkallrrrtest_call_with_call\s<zCallTest.test_call_with_callcCsjt}||d||d||d||d||ddif||dif||ifdS)Nrr"rHr#rr#)rr$rargsrrrtest_empty__Calls    zCallTest.test_empty__CallcCstddif}||d||d||ddif||dif||d||d||if||d||d||difdS) Nr#rr"rUrH)r5rIr5rQrVrrrtest_named_empty_calls      zCallTest.test_named_empty_callcCsftdif}||d||d||ddif||dif||jd||jidS)NrLrKr#rLr#)rr$rWkwargsrVrrrtest_call_with_argss   zCallTest.test_call_with_argscCshtddif}||d||ddif||jd||ji||d||difdS)Nr#rLrZrK)rr$rWr[rRrVrrrtest_named_call_with_argss  z"CallTest.test_named_call_with_argsc Cstdtdddf}||tdddf||dtdddf||ddtdddf||dtdddf||jd||jtddddS)NrrNrPrrr#)rdictr$rWr[rVrrrtest_call_with_kwargsszCallTest.test_call_with_kwargsc Cstddtdddf}||dtdddf||ddtdddf||jd||jtddd||tdddf||dtdddfdS)Nr#rrNrPr^)rr_r$rWr[rRrVrrrtest_named_call_with_kwargssz$CallTest.test_named_call_with_kwargscCsNtdif}||tddd|tddd||tddd|gdS)NrLr>rMrN)rr$rassertInrVrrr#test_call_with_args_call_empty_names z,CallTest.test_call_with_args_call_empty_namecCsR|tdtdd|tdtdddk|tdiftdddkdS)NrKr>rMrNr>rM)rRrr assertFalse assertTruerrrr test_call_neszCallTest.test_call_necCs8td}dd|tfD]}||||||kqdS)NrKr>)rintrRre)rrSvaluerrrtest_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()rLrrzcall(1, 2, 3, a='b')r5zcall.bar(1, 2, 3, a='b')rr>zcall(1)thing)zzzcall(zz='thing')z call().foorNrzcall().foo.bar().bingrMzcall().foo(1, 2, a=3)zcall()()z call()(2)zcall()().bar().baz.beep(1)) r$r*rrr+r#r5bingrJbeeprrrrr,s6zCallTest.test_reprcCs||tddif|tddddddddddft}|d d d|dd d ||jtd d dtdd d gdS) NrGrr#r5rNrP)rrr4r>rMr^)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.bazrrsrMrNrpr^)r$rr#r5rJr 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>rMrNrPrmz ().foo().bar)rNr^rp) rr#r5r$r_rZ call_argsrRrqr9rJro call_list)rresultr(Z last_callrrrtest_extended_callszCallTest.test_extended_callcCs@tddj}tddj}|||||||||dSNr>xrM)rr#r$rRrrrrtest_extended_not_equal*s     z CallTest.test_extended_not_equalcCsHtddj}tddj}|||||||||dSrz)rr#r5r$rRrrrrtest_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>rMrNrP) rr$rrwr9r8rhr#r5rJ__int__)rr(rSrrrtest_call_list:s"$$zCallTest.test_call_listcCs>|ttt}t|||jtg|tg|jdSr)r$rrrrhr9rmrrr test_call_anyOs  zCallTest.test_call_anycCshtdddifdd}|t|d||dd||ddditdddif}|||dS) NrdrrNT)rrMrr>)rr$len)rrWZ other_argsrrrtest_two_args_callXs zCallTest.test_two_args_callcCsJ|tdddd|tddd|tdddifdddS) Nrr#r)r5ZbarzrGrZhelloZworld)r$rrrrrtest_call_with_nameaszCallTest.test_call_with_namec Cst}|d||jtttdtgt}d|d<||jtttddgt}t|||jtttgdS)Nr5r>) rr#r$r9r __getitem__ __setitem__iter__iter__rrrrtest_dunder_callfs$*zCallTest.test_dunder_callN)rrrrTrXrYr\r]r`rarcrgrjr,rrruryr}r~rrrrrrrrrrFZs*%         rFc@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>rMrNrPrm) 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)rrhr7r$rZ 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..FoorNNrrrrrrrrr3sr33rm)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>rMrN)rr&rr)rr#rrrr+test_create_autospec_keyword_only_argumentss  z=SpecSignatureTest.test_create_autospec_keyword_only_argumentscCs6t}dd}||_t|}|d|jddS)NcSsdSrrrmrrrrrz@SpecSignatureTest.test_function_as_instance_attribute..frn)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..FooNrrrrrr3sr3rN)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)NcSsdSrrr{rrrrzpSpecSignatureTest.test_spec_has_descriptor_returning_function..CrazyDescriptor.__get__..r)rrZtype_rrr__get__sz^SpecSignatureTest.test_spec_has_descriptor_returning_function..CrazyDescriptor.__get__NrrrrrrrrCrazyDescriptorsrcseZdZZdS)zNSpecSignatureTest.test_spec_has_descriptor_returning_function..MyClassN)rrr some_attrrrrrMyClasssrr>rM)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|Srrr{rrrrrzgSpecSignatureTest.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>rM)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&srrNr#r5r>rM) 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>rMrN) rrrrrrr$rtrextend)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$rrrhrassertIsInstancerrrrrtest_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)rrrDr(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>rMrNrP)r%rrrassert_called_once_withr)rr3rrrDr(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%BrreZcalledrr$rtrZassertIsr#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)rr|rrrrrzBSpecSignatureTest.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%rrrrrr3sr3rr{r#r5rrp)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..FoorNNrrrrrr3sr3r)r%r3rrrrr)rr3r(instanceZ attr_instanceZ call_resultrrr test_inherits  zSpecSignatureTest.test_inheritcCstdtttdtttitttgtttttttdtttdtttdtddS)Nr>r#g?y?FT)rrhr+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>rMrr^rNrP)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>rMrNcsdddS)Nr>rMrN)rr{srrr 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..FoorNcSsdSrrrrrr__init__rz.Foo.__init__N)rNrrrrrrrrr3sr3r>rmrMrPrr^)r%rrrrrr&rBrrrtest_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)rr|rrrrr1rzDSpecSignatureTest.test_signature_callable..Callable.__init__cSsdSrrrrrr__call__2rzDSpecSignatureTest.test_signature_callable..Callable.__call__N)rrrrrrrrrCallable0srr>rMr|rrrm)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)ri)rrirrrrwszLSpecSignatureTest.test_autospec_data_descriptor..Descriptor.__init__NcSs|Srr)rrrrrrrzszKSpecSignatureTest.test_autospec_data_descriptor..Descriptor.__get__cSsdSrr)rrrirrr__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>rMrNrPrrp)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)NrPrrp) types MethodTypetimectimerr+rrr7)rmethZmockedrrr'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)rrehasattr)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>rMr)rr$inspect signaturer9rrr)rrr(rrrtest_spec_inspect_signatures   z-SpecSignatureTest.test_spec_inspect_signaturecCsd ddddddd}||dddd d t|}|dddd |ddd |t|t|||jtdddd tddd g|t|d|jt|dddd d dS) Nrrh)rrcreturncSs |||Srr)rrrrrrr#szFSpecSignatureTest.test_spec_inspect_signature_annotations..foor>rMrN)rrprP)r)r$rrrr9rrr)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)NcSsdSrrrmrrrrrz@SpecSignatureTest.test_spec_function_assert_has_calls..fr>rM)rr@rrrrrrr#test_spec_function_assert_has_callss  z5SpecSignatureTest.test_spec_function_assert_has_callscCsZdd}t|}|d|d|t|dWdn1sL0YdS)NcSsdSrrrmrrrrrz?SpecSignatureTest.test_spec_function_assert_any_call..fr>rM)rrArrrrrr"test_spec_function_assert_any_calls   z4SpecSignatureTest.test_spec_function_assert_any_callcCsvdd}t}t||d}|dd||jtdg||jtdg|||jg||jgdS)NcSsdSrrrmrrrrrz:SpecSignatureTest.test_spec_function_reset_mock..frr>rM)rrr$r9rr7)rrrvr(rrrtest_spec_function_reset_mocks  z/SpecSignatureTest.test_spec_function_reset_mockN))rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr{sL      &  ,     rc@s,eZdZddZddZddZddZd S) TestCallListcCst}||jt|dd|dd|dd|ddtddtddtddtddfD]}|||jq`tddtddg}|||jtddtddg}|||jtddtddg}|||jtddg}|||j|td|j|tdg|jdS) Nr>rMrNrmrPrprrs)rrrqrrrbZ assertNotIn)rr(rSZcallsrrr!test_args_list_contains_call_lists$    ( z.TestCallList.test_args_list_contains_call_listcCsJt}|dd|jdd|jjdddd}|t|j|dS) Nr>rMrNrmrsZdog)catzU[call(1, 2), call.foo(a=3), call.foo.bar(), call.foo.bar().baz('fish', cat='dog')])rr#r5rJr$r+r9)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_callablerN) r rr rrrrr&r$r9rstop)rrr(rrrrtest_propertymock&szTestCallList.test_propertymockcCs@t}t}|t|_|j}|||t||tdSr)rr rr#rrr)rrrZreturnedrrrtest_propertymock_returnvalue8s  z*TestCallList.test_propertymock_returnvalueN)rrrr!r#r%r&rrrrr sr c@s<eZdZddZddZddZddZd d Zd d Zd S)TestCallablePredicatecCs(ttttttfD]}|t|qdSr)r+bytesrhrtuplerrfr )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)rfr )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-)rfr r,)rr-rrrtest_staticmethodOsz'TestCallablePredicate.test_staticmethodcCs"Gddd}|t|jdS)Nc@seZdZedZdS)zMTestCallablePredicate.test_non_callable_staticmethod..BadStaticMethodN)rrrr not_callablerrrrBadStaticMethodVsr0rer r/)rr0rrrtest_non_callable_staticmethodUsz4TestCallablePredicate.test_non_callable_staticmethodcCs"Gddd}|t|jdS)Nc@seZdZeddZdS)z?TestCallablePredicate.test_classmethod..WithClassMethodcSsdSrr)rrrr classfunc\szITestCallablePredicate.test_classmethod..WithClassMethod.classfuncN)rrrrr3rrrrWithClassMethod[sr4)rfr r3)rr4rrrtest_classmethodZsz&TestCallablePredicate.test_classmethodcCs"Gddd}|t|jdS)Nc@seZdZedZdS)zKTestCallablePredicate.test_non_callable_classmethod..BadClassMethodN)rrrrr/rrrrBadClassMethodasr6r1)rr6rrrtest_non_callable_classmethod`sz3TestCallablePredicate.test_non_callable_classmethodN) rrrr*r+r.r2r5r7rrrrr'Cs r'__main__)rr r ZunittestZ unittest.mockrrrrrrrr r r r functoolsrr%rZTestCaser rFrr r'rmainrrrrs*0  E#G#