f _@sfddlZddlmZmZmZddlmZmZmZm Z m Z m Z m Z Gdddej ZedkrbedS)N) 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,sr(c@s eZdZdS)z.TestCallable.test_subclasses..MagicSubNr%rrrrMagicSub2sr))rrrr!r"rr#)rr(r"r)r#rrrtest_subclasses+s zTestCallable.test_subclassescCsLtdtdd}|}||j|}||||t|dS)N%s.XTspec r rstart addCleanupstopassert_called_once_withrrrrpatcherrinstancerrrtest_patch_spec9s  zTestCallable.test_patch_speccCsLtdtdd}|}||j|}||||t|dS)Nr+Tspec_setr.r3rrrtest_patch_spec_setEs  z TestCallable.test_patch_spec_setcCs@tdttd}|}||j|||t|dS)Nr+r, r rrr/r0r1rrrrr4rrrrtest_patch_spec_instanceQs   z%TestCallable.test_patch_spec_instancecCs@tdttd}|}||j|||t|dS)Nr+r7r:r;rrrtest_patch_spec_set_instanceZs   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 rrrrrrezGTestCallable.test_patch_spec_callable_class..CallableX.__call__N)rr&r'rrrrr CallableXdsr?c@s eZdZdS)z8TestCallable.test_patch_spec_callable_class..SubNr%rrrrSubgsr@c@s eZdZdS)z:TestCallable.test_patch_spec_callable_class..MultiNr%rrrrMultijsrA)r-r8r+Z foobarbaz) rrr rr2rrrrAttributeErrorgetattrZfoo) rr?r@rAargZKlassrr5resultrrrtest_patch_spec_callable_classcs$  z+TestCallable.test_patch_spec_callable_classcCs4tt}|}|t|tt}|t|dSr )r rrr)rrr5rrrtest_create_autospecs   z!TestCallable.test_create_autospeccCs@ttdd}|t|||j|t|jdddS)NT)r5Zsomeargs)r rrrZwibbler2rrrrtest_create_autospec_instances    z*TestCallable.test_create_autospec_instanceN)rr&r'rrr r$r*r6r9r<r=rIrJrLrrrrr s     r __main__)ZunittestZunittest.test.testmock.supportrrrZ unittest.mockrrrrr r r ZTestCaser rmainrrrrs $