diff options
author | Raymond Hettinger <python@rcn.com> | 2007-11-14 23:02:30 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2007-11-14 23:02:30 (GMT) |
commit | b5e5d0741a7a9b8219abac143e06f40b804886c9 (patch) | |
tree | 27bad9c66554a0b924a39f72bdb1243bc9639d6c | |
parent | 78f27e001b5099fee2139afedb2f0992c7022be8 (diff) | |
download | cpython-b5e5d0741a7a9b8219abac143e06f40b804886c9.zip cpython-b5e5d0741a7a9b8219abac143e06f40b804886c9.tar.gz cpython-b5e5d0741a7a9b8219abac143e06f40b804886c9.tar.bz2 |
Add test for __fields__ being read-only
-rw-r--r-- | Lib/test/test_collections.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index 348919f..04d4d9d 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -43,6 +43,14 @@ 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 __dict__ method + # Verify that __fields__ is read-only + try: + p.__fields__ = ('F1' ,'F2') + except AttributeError: + pass + else: + self.fail('The __fields__ attribute needs to be read-only') + # verify that field string can have commas Point = namedtuple('Point', 'x, y') p = Point(x=11, y=22) |