mirror of
https://github.com/python/cpython.git
synced 2025-07-29 06:05:00 +00:00
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.
This commit is contained in:
parent
53e9fa4eed
commit
4e1be94bc6
1 changed files with 4 additions and 1 deletions
|
@ -13,6 +13,7 @@ warnings.filterwarnings("ignore", "integer argument expected",
|
||||||
|
|
||||||
# count the number of test runs.
|
# count the number of test runs.
|
||||||
# used to skip running test_execfile() multiple times
|
# used to skip running test_execfile() multiple times
|
||||||
|
# and to create unique strings to intern in test_intern()
|
||||||
numruns = 0
|
numruns = 0
|
||||||
|
|
||||||
class Squares:
|
class Squares:
|
||||||
|
@ -646,7 +647,9 @@ class BuiltinTest(unittest.TestCase):
|
||||||
|
|
||||||
def test_intern(self):
|
def test_intern(self):
|
||||||
self.assertRaises(TypeError, intern)
|
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)
|
self.assertTrue(intern(s) is s)
|
||||||
s2 = s.swapcase().swapcase()
|
s2 = s.swapcase().swapcase()
|
||||||
self.assertTrue(intern(s2) is s)
|
self.assertTrue(intern(s2) is s)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue