14
14
from test .support .script_helper import assert_python_ok , assert_python_failure
15
15
from test .support import threading_helper
16
16
from test .support import import_helper
17
- from test .support import interpreters
17
+ try :
18
+ from test .support import interpreters
19
+ except ImportError :
20
+ interpreters = None
18
21
import textwrap
19
22
import unittest
20
23
import warnings
21
24
22
25
26
+ def requires_subinterpreters (meth ):
27
+ """Decorator to skip a test if subinterpreters are not supported."""
28
+ return unittest .skipIf (interpreters is None ,
29
+ 'subinterpreters required' )(meth )
30
+
31
+
23
32
# count the number of test runs, used to create unique
24
33
# strings to intern in test_intern()
25
34
INTERN_NUMRUNS = 0
@@ -700,6 +709,7 @@ def __hash__(self):
700
709
701
710
self .assertRaises (TypeError , sys .intern , S ("abc" ))
702
711
712
+ @requires_subinterpreters
703
713
def test_subinterp_intern_dynamically_allocated (self ):
704
714
global INTERN_NUMRUNS
705
715
INTERN_NUMRUNS += 1
@@ -715,6 +725,7 @@ def test_subinterp_intern_dynamically_allocated(self):
715
725
assert id(t) != { id (t )} , (id(t), { id (t )} )
716
726
''' ))
717
727
728
+ @requires_subinterpreters
718
729
def test_subinterp_intern_statically_allocated (self ):
719
730
# See Tools/build/generate_global_objects.py for the list
720
731
# of strings that are always statically allocated.
0 commit comments