summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_collections.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2009-05-27 00:38:24 (GMT)
committerRaymond Hettinger <python@rcn.com>2009-05-27 00:38:24 (GMT)
commit089ba7f69012a51c3c809a4d7bde62d67ebbb537 (patch)
tree182fec8a6a1ad8e89bd9605c8c3c11b302bbc7b5 /Lib/test/test_collections.py
parente261ae0d46d610899fd0822ae9277dd6df54fefe (diff)
downloadcpython-089ba7f69012a51c3c809a4d7bde62d67ebbb537.zip
cpython-089ba7f69012a51c3c809a4d7bde62d67ebbb537.tar.gz
cpython-089ba7f69012a51c3c809a4d7bde62d67ebbb537.tar.bz2
Fix field name conflicts for named tuples.
Diffstat (limited to 'Lib/test/test_collections.py')
-rw-r--r--Lib/test/test_collections.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index c471361..ad79ad5 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -173,6 +173,15 @@ class TestNamedTuple(unittest.TestCase):
self.assertEqual(p, q)
self.assertEqual(p._fields, q._fields)
+ def test_name_conflicts(self):
+ # Some names like "self", "cls", "tuple", "itemgetter", and "property"
+ # failed when used as field names. Test to make sure these now work.
+ T = namedtuple('T', 'itemgetter property self cls tuple')
+ t = T(1, 2, 3, 4, 5)
+ self.assertEqual(t, (1,2,3,4,5))
+ newt = t._replace(itemgetter=10, property=20, self=30, cls=40, tuple=50)
+ self.assertEqual(newt, (10,20,30,40,50))
+
class ABCTestCase(unittest.TestCase):
def validate_abstract_methods(self, abc, *names):