f _c@sfddlZddlmZmZmZddlmZmZmZm Z m Z m Z m Z Gdddej ZedkrbedS)iN) is_instanceX SomeClass)Mock MagicMockNonCallableMagicMockNonCallableMockpatchcreate_autospec CallableMixinc@sleZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZdS) TestCallablecCs$|t|t|t|tdSN) assertTruerr assertFalser selfmockr.MockSubNr __module__ __qualname__rrrrMockSub,r%c@r!)z.TestCallable.test_subclasses..MagicSubNr"rrrrMagicSub2r&r')rr rrrrr)rr%rr'rrrrtest_subclasses+s zTestCallable.test_subclassescCLtdtdd}|}||j|}||||t|dS)N%s.XTspec rrstart addCleanupstopassert_called_once_withrrrrpatcherrinstancerrrtest_patch_spec9  zTestCallable.test_patch_speccCr))Nr*Tspec_setr-r2rrrtest_patch_spec_setEr6z TestCallable.test_patch_spec_setcC@tdttd}|}||j|||t|dS)Nr*r+ rrrr.r/r0rrrrr3rrrrtest_patch_spec_instanceQ   z%TestCallable.test_patch_spec_instancecCr:)Nr*r7r;r<rrrtest_patch_spec_set_instanceZr>z)TestCallable.test_patch_spec_set_instancec CsGdddt}Gddd|}Gdddt|}dD]}|||fD]}tdtfi||i}|}||t|t|t t |d |}||d d d |d d d | d d d |j d d d WdqD1s0YqDq6dS) Nc@seZdZddZdS)z>TestCallable.test_patch_spec_callable_class..CallableXcSsdSr rrrrrreszGTestCallable.test_patch_spec_callable_class..CallableX.__call__N)rr#r$rrrrr CallableXdr&r@c@r!)z8TestCallable.test_patch_spec_callable_class..SubNr"rrrrSubgr&rAc@r!)z:TestCallable.test_patch_spec_callable_class..MultiNr"rrrrMultijr&rB)r,r8r*Z foobarbaziii) rrrrr1r rrrZAttributeErrorZgetattrZfoo) rr@rArBZargZKlassrr4Zresultrrrtest_patch_spec_callable_classcs$  z+TestCallable.test_patch_spec_callable_classcCs4tt}|}|t|tt}|t|dSr )rrrr)rrr4rrrtest_create_autospecs   z!TestCallable.test_create_autospeccCs@ttdd}|t|||j|t|jdddS)NT)r4ZsomeZargs)rrrrZwibbler1rrrrtest_create_autospec_instances    z*TestCallable.test_create_autospec_instanceN)rr#r$rrrr r(r5r9r=r?rCrDrErrrrr s     r Z__main__)ZunittestZunittest.test.testmock.supportrrrZ unittest.mockrrrrrrr ZTestCaser rZmainrrrrZs $