diff options
author | Raymond Hettinger <python@rcn.com> | 2015-08-30 16:13:48 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2015-08-30 16:13:48 (GMT) |
commit | 7a3602e7cf1c0f54d52c563afca50c2e09e7bbf9 (patch) | |
tree | ba15e1f7acbbe28daf54c205f234885423e1b17a /Lib/test/test_collections.py | |
parent | 1a83746418862b7618d888d2e338ad9dd9776313 (diff) | |
download | cpython-7a3602e7cf1c0f54d52c563afca50c2e09e7bbf9.zip cpython-7a3602e7cf1c0f54d52c563afca50c2e09e7bbf9.tar.gz cpython-7a3602e7cf1c0f54d52c563afca50c2e09e7bbf9.tar.bz2 |
Issue #24931: Resolve __dict__ conflict in namedtuple subclasses.
Diffstat (limited to 'Lib/test/test_collections.py')
-rw-r--r-- | Lib/test/test_collections.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index df1c63c..66db90f 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -225,7 +225,6 @@ class TestNamedTuple(unittest.TestCase): self.assertEqual(p._fields, ('x', 'y')) # test _fields attribute self.assertEqual(p._replace(x=1), (1, 22)) # test _replace method self.assertEqual(p._asdict(), dict(x=11, y=22)) # test _asdict method - self.assertEqual(vars(p), p._asdict()) # verify that vars() works try: p._replace(x=1, error=2) @@ -380,6 +379,17 @@ class TestNamedTuple(unittest.TestCase): globals().pop('NTColor', None) # clean-up after this test + def test_namedtuple_subclass_issue_24931(self): + class Point(namedtuple('_Point', ['x', 'y'])): + pass + + a = Point(3, 4) + self.assertEqual(a._asdict(), OrderedDict([('x', 3), ('y', 4)])) + + a.w = 5 + self.assertEqual(a.__dict__, {'w': 5}) + + ################################################################################ ### Abstract Base Classes ################################################################################ |