def test_isa_docstring (self): assert _isa(type).__doc__ == "`True` if `obj` is an instance of :class:`type`" assert _isa((type, object)).__doc__ == "`True` if `obj` is an instance of (type, object)" assert _isa(type, 'foo').__doc__ == 'foo' assert _isa(type, docstring='foo').__doc__ == 'foo' # This is a bit of a roundabout hack to get coverage for an # extremely corner-ish corner case. class C (object): pass C.__name__ = '' assert _isa(C).__doc__ == "`True` if `obj` is an instance of <class 'test_predicates.'>"
def test_isa (self): assert _isa(type)(Thing) assert _isa(Thing)(Thing()) assert _isa(''.__class__)("bad robot!") assert _isa((type, object))(Thing) assert _isa((type, object))(Thing()) assert _isa((type, object))("bad robot!") assert not _isa(type)("bad robot!")
def test_isa_docstring (self): assert _isa(type).__doc__ == "`True` if `obj` is an instance of :class:`type`" assert _isa(type, 'foo').__doc__ == 'foo' assert _isa(type, docstring='foo').__doc__ == 'foo'
def test_is (self): assert _is(None)(None) assert _isa(Thing)(Thing()) assert _isa(''.__class__)("bad robot!")