Commit 3b97951e authored by Robert Bradshaw's avatar Robert Bradshaw

isinstance tests

parent f1b90a19
__doc__ = u"""
>>> test_all()
True
"""
cdef class A:
pass
def test_all():
# Optimized tests.
assert isinstance(type('a',(),{}), type)
assert isinstance(bool(), bool)
assert isinstance(int(), int)
assert isinstance(long(), long)
assert isinstance(float(), float)
assert isinstance(complex(), complex)
assert isinstance(bytes(), bytes)
assert isinstance(str(), str)
assert isinstance(unicode(), unicode)
assert isinstance(tuple(), tuple)
assert isinstance(list(), list)
assert isinstance(dict(), dict)
# if py_ver > (2, 3):
# assert isinstance(set(), set)
assert isinstance(slice(0), slice)
assert isinstance(A, type)
assert isinstance(A(), A)
assert not isinstance("foo", int)
# Non-optimized
foo = A
assert isinstance(A(), foo)
assert isinstance(0, (int, long))
assert not isinstance("xyz", (int, long))
return True
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment