diff options
author | Benjamin Peterson <benjamin@python.org> | 2011-08-16 23:53:26 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2011-08-16 23:53:26 (GMT) |
commit | c4085c847065464de0255c806314e136cd260bdb (patch) | |
tree | 7b5822c2ecb7f7f6f73171b29168ae64b9a79ac4 /Lib/test | |
parent | 51be6e0a0f21ece0fbd6c046616c5b504246b70f (diff) | |
download | cpython-c4085c847065464de0255c806314e136cd260bdb.zip cpython-c4085c847065464de0255c806314e136cd260bdb.tar.gz cpython-c4085c847065464de0255c806314e136cd260bdb.tar.bz2 |
complain when a class variable shadows a name in __slots__ (closes #12766)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_descr.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 1f2039e..3f68ee9 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -4253,6 +4253,14 @@ order (MRO) for bases """ foo = Foo() str(foo) + def test_slot_shadows_class(self): + with self.assertRaises(ValueError) as cm: + class X: + __slots__ = ["foo"] + foo = None + m = str(cm.exception) + self.assertEqual("'foo' in __slots__ conflicts with class variable", m) + class DictProxyTests(unittest.TestCase): def setUp(self): class C(object): |