summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/seq_tests.py7
-rw-r--r--Lib/test/test_collections.py10
2 files changed, 16 insertions, 1 deletions
diff --git a/Lib/test/seq_tests.py b/Lib/test/seq_tests.py
index eb6d141..ebd6157 100644
--- a/Lib/test/seq_tests.py
+++ b/Lib/test/seq_tests.py
@@ -304,6 +304,13 @@ class CommonTest(unittest.TestCase):
self.assertEqual(self.type2test(s)*(-4), self.type2test([]))
self.assertEqual(id(s), id(s*1))
+ def test_bigrepeat(self):
+ x = self.type2test([0])
+ x *= 2**16
+ self.assertRaises(MemoryError, x.__mul__, 2**16)
+ if hasattr(x, '__imul__'):
+ self.assertRaises(MemoryError, x.__imul__, 2**16)
+
def test_subscript(self):
a = self.type2test([10, 11])
self.assertEqual(a.__getitem__(0), 10)
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index 86b47de..0243134 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -48,9 +48,17 @@ class TestNamedTuple(unittest.TestCase):
self.assert_('__dict__' not in dir(p)) # verify instance has no dict
self.assert_('__weakref__' not in dir(p))
self.assertEqual(p.__fields__, ('x', 'y')) # test __fields__ attribute
- self.assertEqual(p.__replace__('x', 1), (1, 22)) # test __replace__ method
+ 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)