Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit44b1e4e

Browse files
authored
gh-108963: using random to generate unique string in sys.intern test (#109491)
1 parentf16e81f commit44b1e4e

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

‎Lib/test/test_sys.py‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
importlocale
66
importoperator
77
importos
8+
importrandom
89
importstruct
910
importsubprocess
1011
importsys
@@ -30,10 +31,6 @@ def requires_subinterpreters(meth):
3031
'subinterpreters required')(meth)
3132

3233

33-
# count the number of test runs, used to create unique
34-
# strings to intern in test_intern()
35-
INTERN_NUMRUNS=0
36-
3734
DICT_KEY_STRUCT_FORMAT='n2BI2n'
3835

3936
classDisplayHookTest(unittest.TestCase):
@@ -696,10 +693,8 @@ def test_43581(self):
696693
self.assertEqual(sys.__stdout__.encoding,sys.__stderr__.encoding)
697694

698695
deftest_intern(self):
699-
globalINTERN_NUMRUNS
700-
INTERN_NUMRUNS+=1
701696
self.assertRaises(TypeError,sys.intern)
702-
s="never interned before"+str(INTERN_NUMRUNS)
697+
s="never interned before"+str(random.randrange(0,10**9))
703698
self.assertTrue(sys.intern(s)iss)
704699
s2=s.swapcase().swapcase()
705700
self.assertTrue(sys.intern(s2)iss)
@@ -717,9 +712,7 @@ def __hash__(self):
717712

718713
@requires_subinterpreters
719714
deftest_subinterp_intern_dynamically_allocated(self):
720-
globalINTERN_NUMRUNS
721-
INTERN_NUMRUNS+=1
722-
s="never interned before"+str(INTERN_NUMRUNS)
715+
s="never interned before"+str(random.randrange(0,10**9))
723716
t=sys.intern(s)
724717
self.assertIs(t,s)
725718

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp