B rR@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|tdS)N) assertTruerr assertFalser )selfmockrH/opt/alt/python37/lib64/python3.7/unittest/test/testmock/testcallable.pyassertNotCallableszTestCallable.assertNotCallablecCsJxDttfD]4}|t||t|d||jjt |qWdS)N__call__) rr assertRaises TypeErrorrhasattrZassertIn __class____name__repr)rrrrrtest_non_callables zTestCallable.test_non_callablecCs$|ttt|tttdS)N)r issubclassrrrr)rrrrtest_hierarchyszTestCallable.test_hierarchycCs<t}|tt|jtt}|tt|jtdS)N) rr rtypeonerrtwor)rrr rrrtest_attributes#szTestCallable.test_attributescCs\Gdddt}|}|tt|j|Gdddt}|}|tt|j|dS)Nc@s eZdZdS)z-TestCallable.test_subclasses..MockSubN)r __module__ __qualname__rrrrMockSub,sr$c@s eZdZdS)z.TestCallable.test_subclasses..MagicSubN)rr"r#rrrrMagicSub2sr%)rr rrrrr )rr$rr%r rrrtest_subclasses+s zTestCallable.test_subclassescCsLtdtdd}|}||j|}||||t|dS)Nz%s.XT)spec) r rstart addCleanupstopassert_called_once_withrrr)rpatcherrinstancerrrtest_patch_spec9s  zTestCallable.test_patch_speccCsLtdtdd}|}||j|}||||t|dS)Nz%s.XT)spec_set) r rr(r)r*r+rrr)rr,rr-rrrtest_patch_spec_setEs  z TestCallable.test_patch_spec_setcCs@tdttd}|}||j|||t|dS)Nz%s.X)r') r rrr(r)r*rrr)rr,rrrrtest_patch_spec_instanceQs   z%TestCallable.test_patch_spec_instancecCs@tdttd}|}||j|||t|dS)Nz%s.X)r/) r rrr(r)r*rrr)rr,rrrrtest_patch_spec_set_instanceZs   z)TestCallable.test_patch_spec_set_instancec CsGdddt}Gddd|}Gdddt|}xdD]}x|||fD]}tdtf||iz}|}||t|t|t t |d |}||d d d |d d d | d d d |j d d d WdQRXqHWq8WdS) Nc@seZdZddZdS)z>TestCallable.test_patch_spec_callable_class..CallableXcSsdS)Nr)rrrrreszGTestCallable.test_patch_spec_callable_class..CallableX.__call__N)rr"r#rrrrr CallableXdsr3c@s eZdZdS)z8TestCallable.test_patch_spec_callable_class..SubN)rr"r#rrrrSubhsr4c@s eZdZdS)z:TestCallable.test_patch_spec_callable_class..MultiN)rr"r#rrrrMultiksr5)r'r/z%s.XZ foobarbaz) rrr rr+r rrrAttributeErrorgetattrZfoo) rr3r4r5argZKlassrr-resultrrrtest_patch_spec_callable_classcs"   z+TestCallable.test_patch_spec_callable_classcCs4tt}|}|t|tt}|t|dS)N)r rrr)rrr-rrrtest_create_autospecs   z!TestCallable.test_create_autospeccCs@ttdd}|t|||j|t|jdddS)NT)r-Zsomeargs)r rrrZwibbler+)rrrrrtest_create_autospec_instances    z*TestCallable.test_create_autospec_instanceN)rr"r#rrrr!r&r.r0r1r2r=r>r@rrrrr s      r __main__)ZunittestZunittest.test.testmock.supportrrrZ unittest.mockrrrrr r r ZTestCaser rmainrrrrs $