diff options
author | Raymond Hettinger <python@rcn.com> | 2010-08-08 01:13:42 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2010-08-08 01:13:42 (GMT) |
commit | d331ce9e6686f180373853fef5d819f36d331d44 (patch) | |
tree | 56c8cc04e49237168a85545285f9cbcacf02ad55 /Lib/test/test_collections.py | |
parent | a6b76ba52e00c47eafba57362184f7779330154a (diff) | |
download | cpython-d331ce9e6686f180373853fef5d819f36d331d44.zip cpython-d331ce9e6686f180373853fef5d819f36d331d44.tar.gz cpython-d331ce9e6686f180373853fef5d819f36d331d44.tar.bz2 |
Issue #9507: Named tuple repr will now automatically display the right
name in a tuple subclass.
Diffstat (limited to 'Lib/test/test_collections.py')
-rw-r--r-- | Lib/test/test_collections.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index 69c4a9f..2af94bf 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -218,6 +218,16 @@ class TestNamedTuple(unittest.TestCase): # test __getnewargs__ self.assertEqual(t.__getnewargs__(), values) + def test_repr(self): + with support.captured_stdout() as template: + A = namedtuple('A', 'x', verbose=True) + self.assertEqual(repr(A(1)), 'A(x=1)') + # repr should show the name of the subclass + class B(A): + pass + self.assertEqual(repr(B(1)), 'B(x=1)') + + class ABCTestCase(unittest.TestCase): def validate_abstract_methods(self, abc, *names): |