summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_collections.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2007-10-08 09:14:28 (GMT)
committerRaymond Hettinger <python@rcn.com>2007-10-08 09:14:28 (GMT)
commit2115bbc4da683e6878b361a80c74203a2559e61d (patch)
tree6336a03ba5981375fed9fb7d88f287535a0fcf57 /Lib/test/test_collections.py
parenta970c2216645a86b532f68bfb93b8ec9da858b0d (diff)
downloadcpython-2115bbc4da683e6878b361a80c74203a2559e61d.zip
cpython-2115bbc4da683e6878b361a80c74203a2559e61d.tar.gz
cpython-2115bbc4da683e6878b361a80c74203a2559e61d.tar.bz2
Add comments to NamedTuple code.
Let the field spec be either a string or a non-string sequence (suggested by Martin Blais with use cases). Improve the error message in the case of a SyntaxError (caused by a duplicate field name).
Diffstat (limited to 'Lib/test/test_collections.py')
-rw-r--r--Lib/test/test_collections.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index 939c3ce..c260bc7 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -40,6 +40,11 @@ class TestNamedTuple(unittest.TestCase):
p = Point(x=11, y=22)
self.assertEqual(repr(p), 'Point(x=11, y=22)')
+ # verify that fieldspec can be a non-string sequence
+ Point = NamedTuple('Point', ('x', 'y'))
+ p = Point(x=11, y=22)
+ self.assertEqual(repr(p), 'Point(x=11, y=22)')
+
def test_tupleness(self):
Point = NamedTuple('Point', 'x y')
p = Point(11, 22)