[Python-checkins] r75887 - python/trunk/Lib/test/test_builtin.py

georg.brandl python-checkins at python.org
Tue Oct 27 23:56:09 CET 2009


Author: georg.brandl
Date: Tue Oct 27 23:56:09 2009
New Revision: 75887

Log:
Make sure every run of test_intern() interns a new string, otherwise that test fails e.g. when some other test in test_builtin fails and it is rerun in verbose mode.

Modified:
   python/trunk/Lib/test/test_builtin.py

Modified: python/trunk/Lib/test/test_builtin.py
==============================================================================
--- python/trunk/Lib/test/test_builtin.py	(original)
+++ python/trunk/Lib/test/test_builtin.py	Tue Oct 27 23:56:09 2009
@@ -13,6 +13,7 @@
 
 # count the number of test runs.
 # used to skip running test_execfile() multiple times
+# and to create unique strings to intern in test_intern()
 numruns = 0
 
 class Squares:
@@ -646,7 +647,9 @@
 
     def test_intern(self):
         self.assertRaises(TypeError, intern)
-        s = "never interned before"
+        # This fails if the test is run twice with a constant string,
+        # therefore append the run counter
+        s = "never interned before " + str(numruns)
         self.assertTrue(intern(s) is s)
         s2 = s.swapcase().swapcase()
         self.assertTrue(intern(s2) is s)


More information about the Python-checkins mailing list