mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Issue #9507: Named tuple repr will now automatically display the right
name in a tuple subclass.
This commit is contained in:
parent
a6b76ba52e
commit
d331ce9e66
4 changed files with 15 additions and 2 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue