diff options
| author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2009-01-13 23:39:22 (GMT) |
|---|---|---|
| committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2009-01-13 23:39:22 (GMT) |
| commit | b54447f31cf8f590ef526d2707f26041720f5784 (patch) | |
| tree | 9f9ba59ce4f5437662fb9b9d4e9c13e2980fc6cf /Lib/test/test_inspect.py | |
| parent | a18392a324ba9ee8b267ac9181a67751d8150abc (diff) | |
| download | cpython-b54447f31cf8f590ef526d2707f26041720f5784.zip cpython-b54447f31cf8f590ef526d2707f26041720f5784.tar.gz cpython-b54447f31cf8f590ef526d2707f26041720f5784.tar.bz2 | |
#1162154: inspect.getmembers() now skips attributes that raise AttributeError,
e.g. a __slots__ attribute which has not been set.
Diffstat (limited to 'Lib/test/test_inspect.py')
| -rw-r--r-- | Lib/test/test_inspect.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py index 300d143..b653f40 100644 --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -91,6 +91,17 @@ class TestPredicates(IsTestBase): 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) |
