File tree 1 file changed +3
-10
lines changed
1 file changed +3
-10
lines changed Original file line number Diff line number Diff line change 5
5
import locale
6
6
import operator
7
7
import os
8
+ import random
8
9
import struct
9
10
import subprocess
10
11
import sys
@@ -30,10 +31,6 @@ def requires_subinterpreters(meth):
30
31
'subinterpreters required' )(meth )
31
32
32
33
33
- # count the number of test runs, used to create unique
34
- # strings to intern in test_intern()
35
- INTERN_NUMRUNS = 0
36
-
37
34
DICT_KEY_STRUCT_FORMAT = 'n2BI2n'
38
35
39
36
class DisplayHookTest (unittest .TestCase ):
@@ -696,10 +693,8 @@ def test_43581(self):
696
693
self .assertEqual (sys .__stdout__ .encoding , sys .__stderr__ .encoding )
697
694
698
695
def test_intern (self ):
699
- global INTERN_NUMRUNS
700
- INTERN_NUMRUNS += 1
701
696
self .assertRaises (TypeError , sys .intern )
702
- s = "never interned before" + str (INTERN_NUMRUNS )
697
+ s = "never interned before" + str (random . randrange ( 0 , 10 ** 9 ) )
703
698
self .assertTrue (sys .intern (s ) is s )
704
699
s2 = s .swapcase ().swapcase ()
705
700
self .assertTrue (sys .intern (s2 ) is s )
@@ -717,9 +712,7 @@ def __hash__(self):
717
712
718
713
@requires_subinterpreters
719
714
def test_subinterp_intern_dynamically_allocated (self ):
720
- global INTERN_NUMRUNS
721
- INTERN_NUMRUNS += 1
722
- s = "never interned before" + str (INTERN_NUMRUNS )
715
+ s = "never interned before" + str (random .randrange (0 , 10 ** 9 ))
723
716
t = sys .intern (s )
724
717
self .assertIs (t , s )
725
718
You can’t perform that action at this time.
0 commit comments