Thomas Wouters avatar Thomas Wouters committed 9cc12bb

Add tests for += and *= on strings, and fix the memory-use estimate for the
list.extend tests (they were estimating half the actual use.)

Comments (0)

Files changed (1)

Lib/test/test_bigmem.py

     def test_concat_large(self, size):
         return self.basic_test_concat(size)
 
+    def basic_test_inplace_concat(self, size):
+        l = [sys.stdout] * size
+        l += l
+        self.assertEquals(len(l), size * 2)
+        self.failUnless(l[0] is l[-1])
+        self.failUnless(l[size - 1] is l[size + 1])
+
+    @bigmemtest(minsize=_2G // 2 + 2, memuse=8)
+    def test_inplace_concat_small(self, size):
+        return self.basic_test_inplace_concat(size)
+
+    @bigmemtest(minsize=_2G + 2, memuse=8)
+    def test_inplace_concat_large(self, size):
+        return self.basic_test_inplace_concat(size)
+
     @bigmemtest(minsize=_2G // 5 + 10, memuse=8*5)
     def test_contains(self, size):
         l = [1, 2, 3, 4, 5] * size
     def test_repeat_large(self, size):
         return self.basic_test_repeat(size)
 
-    # Test repr-result of >2G
+    def basic_test_inplace_repeat(self, size):
+        l = ['']
+        l *= size
+        self.assertEquals(len(l), size)
+        self.failUnless(l[0] is l[-1])
+        del l
+
+        l = [''] * size
+        l *= 2
+        self.assertEquals(len(l), size * 2)
+        self.failUnless(l[size - 1] is l[-1])
+
+    @bigmemtest(minsize=_2G // 2 + 2, memuse=16)
+    def test_inplace_repeat_small(self, size):
+        return self.basic_test_inplace_repeat(size)
+
+    @bigmemtest(minsize=_2G + 2, memuse=16)
+    def test_inplace_repeat_large(self, size):
+        return self.basic_test_inplace_repeat(size)
+
     def basic_test_repr(self, size):
         l = [0] * size
         s = repr(l)
         self.failUnless(l[0] is l[-1])
         self.failUnless(l[size - 1] is l[size + 1])
 
-    @bigmemtest(minsize=_2G // 2 + 2, memuse=8)
+    @bigmemtest(minsize=_2G // 2 + 2, memuse=16)
     def test_extend_small(self, size):
         return self.basic_test_extend(size)
 
-    @bigmemtest(minsize=_2G + 2, memuse=8)
+    @bigmemtest(minsize=_2G + 2, memuse=16)
     def test_extend_large(self, size):
         return self.basic_test_extend(size)
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.