[Python-3000-checkins] r58883 - python/branches/py3k-pep3137/Lib/test/regrtest.py python/branches/py3k-pep3137/Lib/test/test_struct.py

guido.van.rossum python-3000-checkins at python.org
Tue Nov 6 20:21:16 CET 2007


Author: guido.van.rossum
Date: Tue Nov  6 20:21:16 2007
New Revision: 58883

Modified:
   python/branches/py3k-pep3137/Lib/test/regrtest.py
   python/branches/py3k-pep3137/Lib/test/test_struct.py
Log:
Move the char-cache-warming code from test_struct.py to regrtest.py,
so other tests can benefit from it too.


Modified: python/branches/py3k-pep3137/Lib/test/regrtest.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/test/regrtest.py	(original)
+++ python/branches/py3k-pep3137/Lib/test/regrtest.py	Tue Nov  6 20:21:16 2007
@@ -278,6 +278,9 @@
                 huntrleaks[1] = int(huntrleaks[1])
             if len(huntrleaks) == 2 or not huntrleaks[2]:
                 huntrleaks[2:] = ["reflog.txt"]
+            # Avoid false positives due to the character cache in
+            # stringobject.c filling slowly with random data
+            warm_char_cache()
         elif o in ('-M', '--memlimit'):
             test_support.set_memlimit(a)
         elif o in ('-u', '--use'):
@@ -768,6 +771,11 @@
     # Collect cyclic trash.
     gc.collect()
 
+def warm_char_cache():
+    s = bytes(range(256))
+    for i in range(256):
+        s[i:i+1]
+
 def reportdiff(expected, output):
     import difflib
     print("*" * 70)

Modified: python/branches/py3k-pep3137/Lib/test/test_struct.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/test/test_struct.py	(original)
+++ python/branches/py3k-pep3137/Lib/test/test_struct.py	Tue Nov  6 20:21:16 2007
@@ -414,11 +414,6 @@
                 for badobject in "a string", 3+42j, randrange:
                     any_err(struct.pack, direction + code, badobject)
 
-# Warm the character cache
-s = bytes(range(256))
-for i in range(256):
-    s[i:i+1]
-
 for args in [("bB", 1),
              ("hH", 2),
              ("iI", 4),


More information about the Python-3000-checkins mailing list