diff options
author | Raymond Hettinger <python@rcn.com> | 2016-08-16 17:55:43 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2016-08-16 17:55:43 (GMT) |
commit | 6538b430cfa3b076da2f9320bb86aaa3c3c7bcf5 (patch) | |
tree | ab705c5a5f2fd6c4b275b038570ccb85e3d54396 /Lib/test/test_collections.py | |
parent | 3ee933f1c34755bb210e23942d22649a0c38bd23 (diff) | |
download | cpython-6538b430cfa3b076da2f9320bb86aaa3c3c7bcf5.zip cpython-6538b430cfa3b076da2f9320bb86aaa3c3c7bcf5.tar.gz cpython-6538b430cfa3b076da2f9320bb86aaa3c3c7bcf5.tar.bz2 |
Issue #25628: Make namedtuple "rename" and "verbose" parameters keyword-only.
Diffstat (limited to 'Lib/test/test_collections.py')
-rw-r--r-- | Lib/test/test_collections.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index a80c49c..c4c0a16 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -412,6 +412,18 @@ class TestNamedTuple(unittest.TestCase): self.assertEqual(NTColor._fields, ('red', 'green', 'blue')) globals().pop('NTColor', None) # clean-up after this test + def test_keyword_only_arguments(self): + # See issue 25628 + with support.captured_stdout() as template: + NT = namedtuple('NT', ['x', 'y'], verbose=True) + self.assertIn('class NT', NT._source) + with self.assertRaises(TypeError): + NT = namedtuple('NT', ['x', 'y'], True) + + NT = namedtuple('NT', ['abc', 'def'], rename=True) + self.assertEqual(NT._fields, ('abc', '_1')) + with self.assertRaises(TypeError): + NT = namedtuple('NT', ['abc', 'def'], False, True) def test_namedtuple_subclass_issue_24931(self): class Point(namedtuple('_Point', ['x', 'y'])): |