3 Cã\pã@s¼ddlZddlZddlmZmZmZmZmZm Z m Z ddl m Z m Z ddlmZGdd„deƒZGdd„dejƒZGd d „d ejƒZGd d „d ejƒZGd d„dejƒZedkr¸ejƒdS)éN)ÚcallÚcreate_autospecÚ MagicMockÚMockÚANYÚpatchÚ PropertyMock)Ú_CallÚ _CallList)Údatetimec@s&eZdZdd„Zdd„Zddd„ZdS) Ú SomeClasscCsdS)N©)ÚselfÚaÚbr r úl/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/mock/mock/tests/testhelpers.pyÚonesz SomeClass.onecCsdS)Nr )rr r rÚtwosz SomeClass.twoNcCsdS)Nr )rrr r rÚthreeszSomeClass.three)N)Ú__name__Ú __module__Ú __qualname__rrrr r r rr sr c@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) ÚAnyTestcCsF|jttƒƒtƒ}|tƒ|jtƒtƒ}|td|jtddS)N)Úfoo)Ú assertEqualrÚobjectrÚassert_called_with)rÚmockr r rÚtest_anys  zAnyTest.test_anycCs$|jttƒdƒ|jttƒdƒdS)Nz)rÚreprrÚstr)rr r rÚ test_repr'szAnyTest.test_reprcCs,tƒ}|tjƒtjƒd|jttddS)N)r)rr Únowrr)rrr r rÚtest_any_and_datetime,szAnyTest.test_any_and_datetimecCs¼tƒ}tjƒ}Gdd„dtƒ}x˜tjƒ|ƒfD]†}|jƒ||||d|j|||d|ƒj||dttttdtjtttdtƒtƒjttdg}|j||j ƒ|j|j |ƒq.WdS)Nc@seZdZdd„Zdd„ZdS)z9AnyTest.test_any_mock_calls_comparison_order..FoocSsdS)NFr )rÚotherr r rÚ__eq__7sz@AnyTest.test_any_mock_calls_comparison_order..Foo.__eq__cSsdS)NTr )rr$r r rÚ__ne__9sz@AnyTest.test_any_mock_calls_comparison_order..Foo.__ne__N)rrrr%r&r r r rÚFoo6sr')rÚbar)ZzingaÚalpha)Za1Zz99) rr r"rÚ reset_mockÚmethodrrrÚ mock_calls)rrÚdr'Úexpectedr r rÚ$test_any_mock_calls_comparison_order3s z,AnyTest.test_any_mock_calls_comparison_orderN)rrrrr!r#r/r r r rrs rc@s”eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#S)$ÚCallTestcCstƒ}|j|tƒƒ|j|td ƒƒ|j|tffƒƒ|j|tifƒƒ|j|tdffƒƒ|j|tdifƒƒ|j|tdfifƒƒ|j|td ƒƒ|j|tdffƒƒ|j|tdifƒƒ|j|tdfifƒƒtdƒ}|j|tdƒƒ|j|tdƒƒ|j|tdifƒƒ|j|tddifƒƒtdƒ}|j|tdƒƒ|j|tddifƒƒtdƒ}|j|tdƒƒ|j|tddifƒƒ|j|td ƒƒ|j|tdd!ifƒƒtd difƒ}|j|tdfd difƒƒ|j|tdd difƒƒ|j|tfd difƒƒ|j|td difƒƒdS)"NÚrr(ÚbazZspaméééér)r1)r©r3r4r5)r7©r3r4r5)r8©r3r4r5)r1r9)r3r4r5)r3r4r5©r3r4r6)r:©r3r4r5)r1r;)r3r4r5©r3r4r6)rr<©r3r4r6)r1r=)r3r4r6©r3r4r6)r(r>)r3r4r6)r rÚassertNotEqual)rÚkallr r rÚtest_call_with_callOs<zCallTest.test_call_with_callcCsptƒ}|j|fƒ|j|dƒ|j|ffƒ|j|dffƒ|j|dfifƒ|j|difƒ|j|ifƒdS)Nr)r)r r)rÚargsr r rÚtest_empty__Callts  zCallTest.test_empty__CallcCs¤tdfifƒ}|j|dƒ|j|dffƒ|j|dfifƒ|j|difƒ|j|ffƒ|j|fƒ|j|ifƒ|j|dƒ|j|dffƒ|j|difƒdS)Nrr()r)r()r rr?)rrBr r rÚtest_named_empty_call€s   zCallTest.test_named_empty_callcCsJtdifƒ}|j|dƒ|j|d ƒ|j|dd ifƒ|j|d ifƒdS) Nr3r4r5r)r3r4r5©r3r4r5)rE©r3r4r5)rrF)r3r4r5)r3r4r5)r r)rrBr r rÚtest_call_with_argss    zCallTest.test_call_with_argscCsLtddifƒ}|j|dƒ|j|ddifƒ|j|d ƒ|j|d ifƒdS) Nrr3r4r5)r3r4r5©r3r4r5)rrH)r3r4r5©r3r4r5)rI)r3r4r5)r rr?)rrBr r rÚtest_named_call_with_args™s   z"CallTest.test_named_call_with_argscCsxtftdddfƒ}|j|tdddfƒ|j|dtdddfƒ|j|dftdddfƒ|j|ftdddfƒdS)Nr5r6)rrr)r Údictr)rrBr r rÚtest_call_with_kwargs£s zCallTest.test_call_with_kwargscCsztdftdddfƒ}|j|dtdddfƒ|j|dftdddfƒ|j|tdddfƒ|j|ftdddfƒdS)Nrr5r6)rr)r rKrr?)rrBr r rÚtest_named_call_with_kwargs¬s z$CallTest.test_named_call_with_kwargscCsNtdifƒ}|j|tdddƒƒ|jtdddƒ|ƒ|jtdddƒ|gƒdS)Nr3r4r5)r3r4r5)r rrÚassertIn)rrBr r rÚ#test_call_with_args_call_empty_name¶s z,CallTest.test_call_with_args_call_empty_namecCsR|jtdƒtddƒƒ|jtdƒtdddƒkƒ|jtdifƒtdddƒkƒdS) Nr3r4r5©r3r4r5)rP©r3r4r5)rQ)r3r4)r?r rÚ assertFalseZ assertTrue)rr r rÚ test_call_ne½szCallTest.test_call_necCs<tdƒ}x.dd|tfD]}|j||ƒ|j||kƒqWdS)Nr3r4r5©r3r4r5)rT)r Úintr?rR)rr@Úvaluer r rÚtest_call_non_tuplesÃs zCallTest.test_call_non_tuplescCs^|jttƒƒdƒ|jttdƒƒdƒ|jttdddifƒƒd ƒ|jttd dddifƒƒd ƒ|jttƒd ƒ|jttƒd ƒ|jttƒƒdƒ|jttdƒƒd ƒ|jttddƒdƒ|jttƒjƒdƒ|jttdƒjjddjƒdƒ|jttƒjddddƒdƒ|jttƒƒƒdƒ|jttdƒdƒƒdƒ|jttƒƒjƒjj dƒƒdƒdS)Nzcall()rz call.foo()r3r4r5rrzcall(1, 2, 3, a='b')r(zcall.bar(1, 2, 3, a='b')rzcall(1)Úthing)Úzzzcall(zz='thing')z call().foo)rzcall().foo.bar().bingzcall().foo(1, 2, a=3)zcall()()z call()(2)zcall()().bar().baz.beep(1))r)r3r4r5)r3r4r5) rrr rr rr(Úbingr2Úbeep)rr r rr!Ês,zCallTest.test_reprcCs||jtƒdfifƒ|jtddddddd dddœfƒtƒ}|dddƒ|dd d |j|jtdddƒtdd d gƒdS) Nr1rr(r5r6)rrr3r4é)rr)rr()rrrÚcall_args_list)rrr r rÚ test_callés  zCallTest.test_callcCsˆ|jtjdƒdd ifƒ|jtjjdddfddifƒtƒ}|jdddƒ|jjdd d |j|jtjdddƒtjjdd d gƒdS) Nr3rÚeggs)Úfishzbar.bazr`r4r5r\)rr)r3)rrrr(r2rÚ method_calls)rrr r rÚtest_attribute_callôszCallTest.test_attribute_callcCstdƒjdƒjddd}|j|dd tddfƒtƒ}|ddddd|j|jtdddddƒ|j|jtdddƒƒ|j|jtdddddgƒ|j|j tdddddgƒtƒ}|jdƒjƒƒj j ddtjdƒjƒƒj j dd}|j|j d |ƒ|j|j |j ƒƒdS) Nr3r4r5r6)rz ().foo().bar)rrr\)r5éÿÿÿÿ) rrr(rrKrÚ call_argsr?r]r,r2r[Ú call_list)rÚresultrZ last_callr r rÚtest_extended_callszCallTest.test_extended_callcCsðtƒ}|dƒ|jtdƒjƒ|jƒtƒ}|dƒjdƒ|jtdƒjdƒjƒ|jƒtƒ}|dƒjdƒdƒ|jtdƒjdƒdƒjƒ|jƒtƒ}t|dƒjdƒdƒjjj dƒdƒƒtdƒjdƒdƒjjj dƒdƒj ƒ}|j|jƒ|jƒdS)Nr3r4r5r6é) rrrrer,r+rUrr(r2Ú__int__)rrr@r r rÚtest_call_lists$$zCallTest.test_call_listcCs>|jttƒtƒ}t|ƒ|j|jtgƒ|jtg|jƒdS)N)rrrrrUr,)rÚmr r rÚ test_call_any)s  zCallTest.test_call_anycCshtdddifdd}|jt|ƒdƒ|j|dd ƒ|j|dddiƒtd ddifƒ}|j||ƒdS) Nr3r4rr5T)rr)r3r4)r3r4)r3r4)r rÚlen)rrBZ other_argsr r rÚtest_two_args_call2s zCallTest.test_two_args_callN)rrrrArCrDrGrJrLrMrOrSrWr!r^rbrgrjrlrnr r r rr0Ms"%        r0c@sReZdZdd„Zdd„Zdd„Zdd„Zd d „Zej d d „ƒZ d d„Z ej e jdƒdd„ƒZdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zd d!„Zeje jd"ƒd#d$„ƒZd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Z eje jd3ƒd4d5„ƒZ!d6d7„Z"eje jd3ƒd8d9„ƒZ#d:d;„Z$dd?„Z&d@dA„Z'dBdC„Z(dDdE„Z)dFS)GÚSpecSignatureTestcCsì|jtt|dƒ|jddƒ|jjddƒ|jt|jjddƒ|jt|jdƒ|jƒ|jjƒ|jt|jjdƒ|jt|jdƒ|jƒ|jjƒ|jt|jjdƒ|jt|jddƒ|jdƒ|jjdƒ|jdd|jjdddS)Nrr3r4r5r6)r) Ú assertRaisesÚAttributeErrorÚgetattrrrÚAssertionErrorÚ TypeErrorrr)rrr r rÚ_check_someclass_mock>s(        z'SpecSignatureTest._check_someclass_mockcCs*ttƒ}|j|ƒttƒƒ}|j|ƒdS)N)rr ru)rrr r rÚ test_basicYs  zSpecSignatureTest.test_basiccCsPdd„}t|dd}|j|ƒdƒGdd„dtƒ}t|dd}|j|ƒdƒdS)NcSsdS)Nr r r r rÚfasz>SpecSignatureTest.test_create_autospec_return_value..fr)Z return_valuec@s eZdZdS)z@SpecSignatureTest.test_create_autospec_return_value..FooN)rrrr r r rr'fsr')rrr)rrwrr'r r rÚ!test_create_autospec_return_value`s   z3SpecSignatureTest.test_create_autospec_return_valuecCs,ttƒ}t|ƒ|jƒ|j|jjdƒdS)Nr)rrUr*rriZ call_count)rrkr r rÚtest_autospec_reset_mockmsz*SpecSignatureTest.test_autospec_reset_mockcCs>Gdd„dtƒ}tj|dƒ}|jƒ}|ƒjdƒ|jdƒdS)Nc@seZdZdd„ZdS)z;SpecSignatureTest.test_mocking_unbound_methods..FoocSsdS)Nr )rrr r rrvsz?SpecSignatureTest.test_mocking_unbound_methods..Foo.fooN)rrrrr r r rr'usr'rr3)rrÚstartrr)rr'ÚpZmock_foor r rÚtest_mocking_unbound_methodsts   z.SpecSignatureTest.test_mocking_unbound_methodscCsVGdd„dtƒ}t|ƒ}|ƒ}|jt|jdƒ|jdƒ|jjdƒ|jt|jƒdS)Nc@seZdZdd„ZdS)zCSpecSignatureTest.test_create_autospec_unbound_methods..FoocSsdS)Nr )rr r rrƒszGSpecSignatureTest.test_create_autospec_unbound_methods..Foo.fooN)rrrrr r r rr'‚sr'r3)rrrprtrr)rr'ÚklassÚinstancer r rÚ$test_create_autospec_unbound_methodss  z6SpecSignatureTest.test_create_autospec_unbound_methodscCs.Gdd„dtƒ}t|dd}|j|jdƒdS)Nc@seZdZdZdS)zESpecSignatureTest.test_create_autospec_keyword_arguments..Foor5N)rrrrr r r rr'‘sr'Ú3)r)rrrr)rr'rkr r rÚ&test_create_autospec_keyword_argumentss z8SpecSignatureTest.test_create_autospec_keyword_argumentsz(Keyword only arguments Python 3 specificcCsbd}i}t||ƒ|d}t|ƒ}|dƒ|jdƒ|jt|ddƒ|ddd|jddddS)Nz def foo(a, *, b=None): pass rr3r4r5)r)Úexecrrrprt)rZfunc_defÚ namespacerrkr r rÚ+test_create_autospec_keyword_only_arguments–s   z=SpecSignatureTest.test_create_autospec_keyword_only_argumentscCs6tƒ}dd„}||_t|ƒ}|jdƒ|jjdƒdS)NcSsdS)Nr )rr r rrw§sz@SpecSignatureTest.test_function_as_instance_attribute..frZ)r rwrr)rÚobjrwrr r rÚ#test_function_as_instance_attribute¥s  z5SpecSignatureTest.test_function_as_instance_attributecCsvtgƒ}|jdƒ|jjdƒ|jtt|dƒGdd„dtƒ}t|ƒ}|jjdƒ|jjjdƒ|jtt|jdƒdS)Nrc@seZdZgZdS)z0SpecSignatureTest.test_spec_as_list..FooN)rrrrr r r rr'¹sr'r5)rÚappendrrprqrrrr)rrr'r r rÚtest_spec_as_list°s   z#SpecSignatureTest.test_spec_as_listcCs:Gdd„dtƒ}t|ƒ}x||jfD]}|j|ƒq$WdS)Nc@seZdZeƒZdS)z.SpecSignatureTest.test_attributes..SubN)rrrr Úattrr r r rÚSubÃsrŠ)r rr‰ru)rrŠZsub_mockrr r rÚtest_attributesÂsz!SpecSignatureTest.test_attributescCsÚGdd„dtƒ}t|ƒ}|jdƒ|jjdƒ|jtt|jdƒ|jdƒ|jjdƒ|jt|jddƒ|jtt|jdƒ|j ddgƒ|j jddgƒ|jtt|j dƒ|j j dƒ|j j jdƒ|jtt|j dƒdS)Nc@seZdZdd„ZeZiZdS)zGSpecSignatureTest.test_builtin_functions_types..BuiltinSubclasscSsdS)Nr )rÚargr r rr(ÑszKSpecSignatureTest.test_builtin_functions_types..BuiltinSubclass.barN)rrrr(Úsortedr‰r r r rÚBuiltinSubclassÐsrŽr5rr(r3r4) Úlistrr‡rrprqrrr(rtrr‰Úpop)rrŽrr r rÚtest_builtin_functions_typesÌs     z.SpecSignatureTest.test_builtin_functions_typescCs¾Gdd„dtƒ}t|ƒ}|jddƒ|jƒ|jdƒtjddƒtjƒtjdƒg}|j|j|ƒ|jjddƒ|jjƒ|jjdƒ|j tjjddƒtjjƒtjjdƒgƒ|j|j|ƒdS)Nc@seZdZeƒZdS)z0SpecSignatureTest.test_method_calls..SubN)rrrr r‰r r r rrŠêsrŠr3r4r5) r rrrrrrrar‰Úextend)rrŠrr.r r rÚtest_method_callsés    $z#SpecSignatureTest.test_method_callscCs|Gdd„dtƒ}t|ƒ}|jt|ƒgƒ|jtt|ƒ|jtt|jƒ|jt|ƒgƒ|j|dtƒ|j|jdtƒdS)Nc@seZdZiZdS)z=SpecSignatureTest.test_magic_methods..BuiltinSubclassN)rrrr‰r r r rrŽsrŽr) rrrrprtrUr‰ÚassertIsInstancer)rrŽrr r rÚtest_magic_methodsÿsz$SpecSignatureTest.test_magic_methodscCsdGdd„dtƒ}xN||ƒfD]@}t|dd}|j|ƒ|jtt|ddƒ|jtt|jddƒqWdS)Nc@seZdZeƒZdS)z,SpecSignatureTest.test_spec_set..SubN)rrrr r‰r r r rrŠsrŠT)Zspec_setrr()r rrurprqÚsetattrr‰)rrŠÚspecrr r rÚ test_spec_set s   zSpecSignatureTest.test_spec_setcCs’Gdd„dtƒ}Gdd„d|ƒ}Gdd„dt|ƒ}xZ||ƒ||ƒ||ƒfD]@}t|ƒ}|jddƒ|jjddƒ|jd d ƒ|jjd d ƒqJWdS) Nc@s$eZdZedd„ƒZedd„ƒZdS)z/SpecSignatureTest.test_descriptors..FoocSsdS)Nr )Úclsrrr r rrwsz1SpecSignatureTest.test_descriptors..Foo.fcSsdS)Nr )rrr r rÚgsz1SpecSignatureTest.test_descriptors..Foo.gN)rrrÚ classmethodrwÚ staticmethodršr r r rr's r'c@s eZdZdS)z/SpecSignatureTest.test_descriptors..BarN)rrrr r r rÚBar"src@s eZdZdS)z/SpecSignatureTest.test_descriptors..BazN)rrrr r r rÚBaz%sržr3r4r5r6)rr rrwÚassert_called_once_withrš)rr'rržr—rr r rÚtest_descriptorss  z"SpecSignatureTest.test_descriptorsz No old style classes in Python 3cs´Gdd„dƒ‰G‡fdd„dˆƒ}x\ˆˆƒ||ƒfD]H}t|ƒ}|jddƒ|jjddƒ|jtt|dƒ|jtt|jdƒq4W|jjddƒ|jjjddƒ|jtt|jdƒdS)Nc@seZdZdd„ZdS)z5SpecSignatureTest.test_old_style_classes..FoocSsdS)Nr )rrrr r rrw4sz7SpecSignatureTest.test_old_style_classes..Foo.fN)rrrrwr r r rr'3sr'cseZdZ”ƒZdS)z5SpecSignatureTest.test_old_style_classes..BarN)rrrršr )r'r rr7srr3r4r)rrwrŸrprqrrrš)rrr—rr )r'rÚtest_old_style_classes1s z(SpecSignatureTest.test_old_style_classescCs Gdd„dtƒ}||_t|ƒ}|ƒ|j|jjƒ|jƒ|jjƒ|j|jtjƒtjjƒgƒ|j |j |j ƒ|j |j |j ƒ|j j ƒ|jt|j j jƒdS)Nc@seZdZdd„ZdZeZdS)z+SpecSignatureTest.test_recursive..AcSsdS)Nr )rr r rrIsz-SpecSignatureTest.test_recursive..A.az foo bar bazN)rrrrrr(r r r rÚAHsr¢)rÚBrrRÚcalledrrrarZassertIsrr(Ú assertIsNotÚlowerrprsr)rr¢rr r rÚtest_recursiveGs  z SpecSignatureTest.test_recursivecCsbGdd„dtƒ}t|ƒ}|j||ƒƒxZ||ƒfD]L}|jdd|jjdd|jjdƒ|jt|jddƒ|jtt|dƒq2Wt|ƒƒ}|jdƒ|jjdƒ|jjdd|jt|jddƒ|jtt|dƒ|jt|ƒ|j j dƒ|j j jdƒ|j j jdd |jtt|j d ƒ|j ƒj dƒ|j ƒj jdƒ|j ƒj jdd |jtt|j ƒd ƒdS) Nc@s$eZdZdd„ZGdd„deƒZdS)z@SpecSignatureTest.test_spec_inheritance_for_classes..FoocSsdS)Nr )rÚxr r rr`szBSpecSignatureTest.test_spec_inheritance_for_classes..Foo.ac@seZdZdd„ZdS)zDSpecSignatureTest.test_spec_inheritance_for_classes..Foo.BarcSsdS)Nr )rÚyr r rrwcszFSpecSignatureTest.test_spec_inheritance_for_classes..Foo.Bar.fN)rrrrwr r r rrbsrN)rrrrrrr r r rr'_sr'rh)r¨rr(rr\)r©rš) rrr¥rrrprtrqrrrrw)rr'Z class_mockZ this_mockZ instance_mockr r rÚ!test_spec_inheritance_for_classes^s0       z3SpecSignatureTest.test_spec_inheritance_for_classescCsŽGdd„dtƒ}||_t|ƒ}|ƒ}|jtt|dƒ|jƒ}|jtt|dƒt|ƒƒ}|jtt|dƒ|jt|ƒ|jƒ}|jtt|dƒdS)Nc@seZdZdZdS)z+SpecSignatureTest.test_inherit..Foor5N)rrrrr r r rr'‡sr'r)rr'rrprqrrrt)rr'rr~Z attr_instanceZ call_resultr r rÚ test_inherit†s  zSpecSignatureTest.test_inheritcCs†tdƒttƒtdƒttƒtiƒttƒtgƒttƒttƒƒttƒtdƒttƒtdƒttƒtdƒtdƒdS)Nr3rgð?yð?FT)rrUr rKrÚsetÚfloatÚcomplex)rr r rÚ test_builtinsžs  zSpecSignatureTest.test_builtinscCs˜dd„}t|ƒ}|jt|ƒ|ddƒ|jddƒ|jddd|jddd||_t|ƒ}|jt|jƒ|jddƒ|jjddƒ|jjddddS) NcSsdS)Nr )rrr r rrw´sz*SpecSignatureTest.test_function..fr3r4)r)rrr5r6)rrprtrrw)rrwrr r rÚ test_function³s    zSpecSignatureTest.test_functioncsvGdd„dtƒ‰G‡fdd„dtƒ}t|ƒ‰|jt‡fdd„ƒˆjddƒ|jt‡fd d„ƒˆj}|j|jfdS) Nc@seZdZddd„ZdS)z;SpecSignatureTest.test_skip_attributeerrors..RaiserNcSs|dkrtdƒ‚dS)Nz$Can only be accessed via an instance)rq)rr…Útyper r rÚ__get__ÈszCSpecSignatureTest.test_skip_attributeerrors..Raiser.__get__)N)rrrr²r r r rÚRaiserÇsr³cseZdZ”ƒZedd„ƒZdS)z@SpecSignatureTest.test_skip_attributeerrors..RaiserClasscSs||S)Nr )rrr r rÚexistingÏszISpecSignatureTest.test_skip_attributeerrors..RaiserClass.existingN)rrrÚraiserrœr´r )r³r rÚ RaiserClassÌsr¶csˆjdddƒS)Nr3r4r5)r´)r¨)Úsr rÚÔsz=SpecSignatureTest.test_skip_attributeerrors..r3r4csˆjS)N)Z nonexistingr )r·r rr¸Ös) rrrprtr´rqrµrr()rr¶r…r )r³r·rÚtest_skip_attributeerrorsÆs z+SpecSignatureTest.test_skip_attributeerrorscCsPGdd„dtƒ}t|ƒ}|jt|ƒ|dƒ|jdƒ|ddƒ|jddƒdS)Nc@seZdZddd„ZdS)z3SpecSignatureTest.test_signature_class..Foor5cSsdS)Nr )rrrr r rÚ__init__ßsz.Foo.__init__N)r5)rrrrºr r r rr'Þsr'r3r6rh)rrrprtrŸr)rr'rr r rÚtest_signature_classÝs   z&SpecSignatureTest.test_signature_classz no old style classes in Python 3cCsŒGdd„dƒ}t|ƒ}|jt|ƒ|dƒ|jdƒ|jdd|jt|jdƒ|ddƒ|jddƒ|jddd|jt|jddddS) Nc@seZdZddd„ZdS)z=SpecSignatureTest.test_signature_old_style_class..Foor5cSsdS)Nr )rrrr r rrºïszFSpecSignatureTest.test_signature_old_style_class..Foo.__init__N)r5)rrrrºr r r rr'îsr'r3)rr4r6rh)rr)rrprtrŸrsr)rr'rr r rÚtest_signature_old_style_classìs     z0SpecSignatureTest.test_signature_old_style_classcCsGdd„dtƒ}t|ƒdS)Nc@s eZdZdS)z6SpecSignatureTest.test_class_with_no_init..FooN)rrrr r r rr'sr')rr)rr'r r rÚtest_class_with_no_initsz)SpecSignatureTest.test_class_with_no_initcCsGdd„dƒ}t|ƒdS)Nc@s eZdZdS)z@SpecSignatureTest.test_old_style_class_with_no_init..FooN)rrrr r r rr' sr')r)rr'r r rÚ!test_old_style_class_with_no_initsz3SpecSignatureTest.test_old_style_class_with_no_initcCsäGdd„dtƒ}t|ƒ}|ddƒ|jddƒ|jddd|jt|dƒ|ddƒ}|jt|ƒ|dd|jdƒ|jdd|dƒ|jdƒ|jddt|ddƒƒ}|dd|jdd|jt|ƒ|dƒ|jdƒdS)Nc@seZdZdd„Zdd„ZdS)z;SpecSignatureTest.test_signature_callable..CallablecSsdS)Nr )rr¨r©r r rrºszDSpecSignatureTest.test_signature_callable..Callable.__init__cSsdS)Nr )rrr r rÚ__call__szDSpecSignatureTest.test_signature_callable..Callable.__call__N)rrrrºr¿r r r rÚCallablesrÀr3r4)r¨r©r)r)rrrŸrprtr)rrÀrr~r r rÚtest_signature_callables(            z)SpecSignatureTest.test_signature_callablecCsvGdd„dtƒ}t|ƒ}|ƒ}|jƒ|jt|dƒ|jt|ƒ|jt|dƒt|ƒƒ}|jt|ƒ|jt|dƒdS)Nc@seZdZdd„ZdS)zASpecSignatureTest.test_signature_noncallable..NonCallablecSsdS)Nr )rr r rrº1szJSpecSignatureTest.test_signature_noncallable..NonCallable.__init__N)rrrrºr r r rÚ NonCallable0srÂr)rrrŸrprt)rrÂrr~r r rÚtest_signature_noncallable/s   z,SpecSignatureTest.test_signature_noncallablecCsDGdd„dtƒ}t|ƒ}|j}|j|tdƒƒ|jƒ|jjƒdS)Nc@seZdZdZdS)z8SpecSignatureTest.test_create_autospec_none..FooN)rrrr(r r r rr'Asr')rrr(ÚassertNotIsInstancer±rrŸ)rr'rÚnoner r rÚtest_create_autospec_none@s z+SpecSignatureTest.test_create_autospec_nonecCsfGdd„dtƒ}t|ƒ}|jdƒ|jjdƒ|jjdd|jdd|jjdƒ|jjdddS)Nc@seZdZdd„ZdS)zMSpecSignatureTest.test_autospec_functions_with_self_in_odd_place..FoocSsdS)Nr )rrr r rrwNszOSpecSignatureTest.test_autospec_functions_with_self_in_odd_place..Foo.fN)rrrrwr r r rr'Msr'é )r)rrrwr)rr'rr r rÚ.test_autospec_functions_with_self_in_odd_placeLs    z@SpecSignatureTest.test_autospec_functions_with_self_in_odd_placecCsfGdd„dtƒ}t|ƒ}|j}|j|tƒ|dddƒ|jdddƒ|jdddƒ|jjdddƒdS) Nc@seZdZedd„ƒZdS)z5SpecSignatureTest.test_autospec_property..FoocSsdS)Nr5r )rr r rr\sz9SpecSignatureTest.test_autospec_property..Foo.fooN)rrrÚpropertyrr r r rr'[sr'r3r4r5r6rhr\)rrrr”rÚabcrŸ)rr'rZ mock_propertyr r rÚtest_autospec_propertyZs  z(SpecSignatureTest.test_autospec_propertycCsZGdd„dtƒ}t|ƒ}|j}|dddƒ|jdddƒ|jdddƒ|jjdddƒdS) Nc@seZdZdgZdS)z2SpecSignatureTest.test_autospec_slots..FoorN)rrrÚ __slots__r r r rr'lsr'r3r4r5r6rhr\)rrrrÊrŸ)rr'rZ mock_slotr r rÚtest_autospec_slotsks z%SpecSignatureTest.test_autospec_slotsN)*rrrrurvrxryr|ÚunittestZexpectedFailurerrZ skipUnlessÚsixÚPY3r„r†rˆr‹r‘r“r•r˜r ÚskipIfr¡r§rªr«r¯r°r¹r»r¼r½r¾rÁrÃrÆrÈrËrÍr r r rro<sB     (  roc@sBeZdZdd„Zdd„Zejejdƒdd„ƒZ dd „Z d d „Z d S) Ú TestCallListcCs"tƒ}|j|jtƒ|ddƒ|dd|ddƒ|ddx:tddƒtddtddƒtddfD]}|j||jƒqbWtddtddƒg}|j||jƒtddƒtddg}|j||jƒtddƒtddg}|j||jƒtddƒg}|j||jƒ|jtdƒ|jƒ|jtdƒg|jƒdS) Nr3r4r5)rr6r\)rr`)rr”r]r rrNZ assertNotIn)rrr@Zcallsr r rÚ!test_args_list_contains_call_list{s$    * z.TestCallList.test_args_list_contains_call_listcCsJtƒ}|ddƒ|jdd|jjƒjdddd}|jt|jƒ|ƒdS) Nr3r4r5)rr`Zdog)ÚcatzU[call(1, 2), call.foo(a=3), call.foo.bar(), call.foo.bar().baz('fish', cat='dog')])rrr(r2rr r,)rrr.r r rÚtest_call_list_str”s   zTestCallList.test_call_list_strz)Unicode is properly handled with Python 3cCs@tƒ}Gdd„dtƒ}|ftdƒ|ƒiŽ|jt|jƒdƒdS)Nc@seZdZdd„ZdS)z9TestCallList.test_call_list_unicode..NonAsciiReprcSsdS)Nõér )rr r rÚ__repr__©szBTestCallList.test_call_list_unicode..NonAsciiRepr.__repr__N)rrrr×r r r rÚ NonAsciiRepr¨srØru [call(a=é)])rrÚunicoderr r,)rrrØr r rÚtest_call_list_unicode£sz#TestCallList.test_call_list_unicodec Cs†tdttd}|jƒ}z^tj|jƒtƒ}|j|jƒ|j|j t ƒt ƒgƒd|_|j|j t ƒt ƒt dƒgƒWd|j ƒXdS)Nz%s.SomeClass.one)Z new_callabler5) rrrrzr rrŸrrr,rÚstop)rr{rr·r r rÚtest_propertymock±s zTestCallList.test_propertymockcCs@tƒ}tƒ}|t|ƒ_|j}|jƒ|j|tƒ|j|tƒdS)N)rrr±rrŸr”rÄ)rrkr{Zreturnedr r rÚtest_propertymock_returnvalueÃs  z*TestCallList.test_propertymock_returnvalueN) rrrrÓrÕrÎrÑrÏrÐrÚrÜrÝr r r rrÒys rÒÚ__main__)rÏZ unittest2rÎrrrrrrrrZ mock.mockr r r rr ZTestCaserr0rorÒrÚmainr r r rÚs $  3pAU