summaryrefslogtreecommitdiff
path: root/Lib/test/test_collections.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-01-05 02:17:24 +0000
committerRaymond Hettinger <python@rcn.com>2008-01-05 02:17:24 +0000
commit1b50fd7cb3e9a4483f6da49c027ebde4501d1c17 (patch)
tree5fbe7ba58aafb667a6c6e14920e17a7f19f9456c /Lib/test/test_collections.py
parent02740f73ff0f12d276ef16b73208d4f9f8d62baa (diff)
downloadcpython-git-1b50fd7cb3e9a4483f6da49c027ebde4501d1c17.tar.gz
Add error-checking to namedtuple's _replace() method.
Diffstat (limited to 'Lib/test/test_collections.py')
-rw-r--r--Lib/test/test_collections.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index c17b76dffe..dd9982af3c 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -55,6 +55,13 @@ class TestNamedTuple(unittest.TestCase):
self.assertEqual(p._replace(x=1), (1, 22)) # test _replace method
self.assertEqual(p._asdict(), dict(x=11, y=22)) # test _asdict method
+ try:
+ p._replace(x=1, error=2)
+ except ValueError:
+ pass
+ else:
+ self._fail('Did not detect an incorrect fieldname')
+
# verify that field string can have commas
Point = namedtuple('Point', 'x, y')
p = Point(x=11, y=22)