mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
fix inspect.isclass() on instances with a custom __getattr__ #1225107
This commit is contained in:
parent
59ce042766
commit
5e5fbb612d
3 changed files with 16 additions and 2 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue