From: Raymond Hettinger Date: Wed, 14 Nov 2007 23:02:30 +0000 (+0000) Subject: Add test for __fields__ being read-only X-Git-Tag: v2.6a1~1056 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b5e5d0741a7a9b8219abac143e06f40b804886c9;p=thirdparty%2FPython%2Fcpython.git Add test for __fields__ being read-only --- diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index 348919f42d00..04d4d9d24699 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)