Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Lib/test/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,21 @@
from test.support.script_helper import assert_python_ok, assert_python_failure
from test.support import threading_helper
from test.support import import_helper
from test.support import interpreters
import textwrap
import unittest
import warnings

try:
from test.support import interpreters
except ImportError:
interpreters = None


def requires_subinterpreters(func):
deco = unittest.skipIf(interpreters is None,
'Test requires subinterpreters')
return deco(func)


DICT_KEY_STRUCT_FORMAT = 'n2BI2n'

Expand Down Expand Up @@ -700,6 +710,7 @@ def __hash__(self):

self.assertRaises(TypeError, sys.intern, S("abc"))

@requires_subinterpreters
def test_subinterp_intern_dynamically_allocated(self):
s = "never interned before" + str(random.randrange(0, 10**9))
t = sys.intern(s)
Expand All @@ -713,6 +724,7 @@ def test_subinterp_intern_dynamically_allocated(self):
assert id(t) != {id(t)}, (id(t), {id(t)})
'''))

@requires_subinterpreters
def test_subinterp_intern_statically_allocated(self):
# See Tools/build/generate_global_objects.py for the list
# of strings that are always statically allocated.
Expand Down