]> granicus.if.org Git - python/commitdiff
Make sure every run of test_intern() interns a new string, otherwise that test fails...
authorGeorg Brandl <georg@python.org>
Tue, 27 Oct 2009 22:56:09 +0000 (22:56 +0000)
committerGeorg Brandl <georg@python.org>
Tue, 27 Oct 2009 22:56:09 +0000 (22:56 +0000)
Lib/test/test_builtin.py

index 3cd5bd955f1627f8ae3c8793ccd31123b9723649..62dca5bd1fcb9ffa6358b22fb6aca73bdb309b96 100644 (file)
@@ -13,6 +13,7 @@ warnings.filterwarnings("ignore", "integer argument expected",
 
 # 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 @@ class BuiltinTest(unittest.TestCase):
 
     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)