1. python_mirrors
  2. cpython

Commits

Serhiy Storchaka  committed ec3a35a Draft

Add bigmemtest decorator to test of issue #16335.

  • Participants
  • Parent commits 38a10d0
  • Branches 2.7

Comments (0)

Files changed (1)

File Lib/test/test_ucn.py

View file
  • Ignore whitespace
 """#"
 
 import unittest
+import sys
 import _testcapi
 
 from test import test_support
 
     @unittest.skipUnless(_testcapi.INT_MAX < _testcapi.PY_SSIZE_T_MAX,
                          "needs UINT_MAX < SIZE_MAX")
-    def test_issue16335(self):
+    @unittest.skipUnless(_testcapi.UINT_MAX < sys.maxint,
+                         "needs UINT_MAX < sys.maxint")
+    @test_support.bigmemtest(minsize=_testcapi.UINT_MAX + 1,
+                             memuse=1 + 4 // len(u'\U00010000'))
+    def test_issue16335(self, size):
         # very very long bogus character name
-        try:
-            x = b'\\N{SPACE' + b'x' * int(_testcapi.UINT_MAX + 1) + b'}'
-            self.assertEqual(len(x), len(b'\\N{SPACE}') +
-                                     (_testcapi.UINT_MAX + 1))
-            self.assertRaisesRegexp(UnicodeError,
-                'unknown Unicode character name',
-                x.decode, 'unicode-escape'
-            )
-        except MemoryError:
-            raise unittest.SkipTest("not enough memory")
+        x = b'\\N{SPACE' + b'x' * int(_testcapi.UINT_MAX + 1) + b'}'
+        self.assertEqual(len(x), len(b'\\N{SPACE}') +
+                                    (_testcapi.UINT_MAX + 1))
+        self.assertRaisesRegexp(UnicodeError,
+            'unknown Unicode character name',
+            x.decode, 'unicode-escape'
+        )
 
 
 def test_main():