Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_inspect.py @ 50784:65c1938fb9ff legacy-trunk
#1162154: inspect.getmembers() now skips attributes that raise AttributeError,
e.g. a __slots__ attribute which has not been set.
| author | Amaury Forgeot d'Arc <amauryfa@gmail.com> |
|---|---|
| date | Tue, 13 Jan 2009 23:39:22 +0000 |
| parents | 4264cf00a75c |
| children | 35bf8f7a8edc |
line wrap: on
line diff
--- a/Lib/test/test_inspect.py Tue Jan 13 23:19:08 2009 +0000 +++ b/Lib/test/test_inspect.py Tue Jan 13 23:39:22 2009 +0000 @@ -91,6 +91,17 @@ self.assert_(inspect.isroutine(mod.spam)) self.assert_(inspect.isroutine([].count)) + def test_get_slot_members(self): + class C(object): + __slots__ = ("a", "b") + + x = C() + x.a = 42 + members = dict(inspect.getmembers(x)) + self.assert_('a' in members) + self.assert_('b' not in members) + + class TestInterpreterStack(IsTestBase): def __init__(self, *args, **kwargs): unittest.TestCase.__init__(self, *args, **kwargs)
