o =?h@sjddlZddlmZmZmZddlmZmZmZm Z m Z m Z m Z Gdddej Zedkr3edSdS)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 selfmockrJ/opt/alt/python310/lib64/python3.10/unittest/test/testmock/testcallable.pyassertNotCallablezTestCallable.assertNotCallablecCsFttfD]}|t||t|d||jjt |qdS)N__call__) rr assertRaises TypeErrorrhasattrZassertIn __class____name__reprrrrrtest_non_callables  zTestCallable.test_non_callablecCs$|ttt|tttdSr )r issubclassrrrrrrrrtest_hierarchyrzTestCallable.test_hierarchycCs<t}|tt|jtt}|tt|jtdSr ) rrrtypeonerrtwor)rr#r$rrrtest_attributes#szTestCallable.test_attributescCs\Gdddt}|}|tt|j|Gdddt}|}|tt|j|dS)Nc@ eZdZdS)z-TestCallable.test_subclasses..MockSubNr __module__ __qualname__rrrrMockSub,r*c@r&)z.TestCallable.test_subclasses..MagicSubNr'rrrrMagicSub2r+r,)rrrr"r#rr$)rr*r#r,r$rrrtest_subclasses+s zTestCallable.test_subclassescCLtdtdd}|}||j|}||||t|dS)N%s.XTspec r rstart addCleanupstopassert_called_once_withrrrrpatcherrinstancerrrtest_patch_spec9  zTestCallable.test_patch_speccCr.)Nr/Tspec_setr2r7rrrtest_patch_spec_setEr;z TestCallable.test_patch_spec_setcC@tdttd}|}||j|||t|dS)Nr/r0 r rrr3r4r5rrrrr8rrrrtest_patch_spec_instanceQ   z%TestCallable.test_patch_spec_instancecCr?)Nr/r<r@rArrrtest_patch_spec_set_instanceZrCz)TestCallable.test_patch_spec_set_instancec CsGdddt}Gddd|}Gdddt|}dD]`}|||fD]X}tdtfi||iB}|}||t|t|t t |d |}||d d d |d d d | d d d |j d d d Wdn1suwYq"qdS) Nc@seZdZddZdS)z>TestCallable.test_patch_spec_callable_class..CallableXcSsdSr rr rrrreszGTestCallable.test_patch_spec_callable_class..CallableX.__call__N)rr(r)rrrrr CallableXds rEc@r&)z8TestCallable.test_patch_spec_callable_class..SubNr'rrrrSubgr+rFc@r&)z:TestCallable.test_patch_spec_callable_class..MultiNr'rrrrMultijr+rG)r1r=r/Z foobarbaz) rrr rr6rrrrAttributeErrorgetattrZfoo) rrErFrGargZKlassrr9resultrrrtest_patch_spec_callable_classcs,  z+TestCallable.test_patch_spec_callable_classcCs4tt}|}|t|tt}|t|dSr )r rrr)rrr9rrrtest_create_autospecs   z!TestCallable.test_create_autospeccCs@ttdd}|t|||j|t|jdddS)NT)r9Zsomeargs)r rrrZwibbler6rrrrtest_create_autospec_instances   z*TestCallable.test_create_autospec_instanceN)rr(r)rrr!r%r-r:r>rBrDrOrPrRrrrrr s     r __main__)ZunittestZunittest.test.testmock.supportrrrZ unittest.mockrrrrr r r ZTestCaser rmainrrrrs$