summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_inspect.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-01-17 22:27:54 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-01-17 22:27:54 (GMT)
commit5e5fbb612d8109078c2777e1759277f9144616d0 (patch)
tree31cc5456eb32eb87d987bcdaea2a91a090947bf7 /Lib/test/test_inspect.py
parent59ce042766d95a1471b08241038b8e0f4a65743a (diff)
downloadcpython-5e5fbb612d8109078c2777e1759277f9144616d0.zip
cpython-5e5fbb612d8109078c2777e1759277f9144616d0.tar.gz
cpython-5e5fbb612d8109078c2777e1759277f9144616d0.tar.bz2
fix inspect.isclass() on instances with a custom __getattr__ #1225107
Diffstat (limited to 'Lib/test/test_inspect.py')
-rw-r--r--Lib/test/test_inspect.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index b653f40..7312cac 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -65,7 +65,6 @@ class TestPredicates(IsTestBase):
def test_excluding_predicates(self):
self.istest(inspect.isbuiltin, 'sys.exit')
self.istest(inspect.isbuiltin, '[].append')
- self.istest(inspect.isclass, 'mod.StupidGit')
self.istest(inspect.iscode, 'mod.spam.func_code')
self.istest(inspect.isframe, 'tb.tb_frame')
self.istest(inspect.isfunction, 'mod.spam')
@@ -91,6 +90,18 @@ class TestPredicates(IsTestBase):
self.assert_(inspect.isroutine(mod.spam))
self.assert_(inspect.isroutine([].count))
+ def test_isclass(self):
+ self.istest(inspect.isclass, 'mod.StupidGit')
+ self.assertTrue(inspect.isclass(list))
+
+ class newstyle(object): pass
+ self.assertTrue(inspect.isclass(newstyle))
+
+ class CustomGetattr(object):
+ def __getattr__(self, attr):
+ return None
+ self.assertFalse(inspect.isclass(CustomGetattr()))
+
def test_get_slot_members(self):
class C(object):
__slots__ = ("a", "b")