From eae92c32e3da33d2f263856faa9d0aa81843c136 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Thu, 27 Jul 2023 15:16:19 -0600 Subject: [PATCH] Skip subinterpreter tests when not supported. --- Lib/test/test_sys.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 78ed4bbaad4eb6..9dce15ed1529e7 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -14,12 +14,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 +try: + from test.support import interpreters +except ImportError: + interpreters = None import textwrap import unittest import warnings +def requires_subinterpreters(meth): + """Decorator to skip a test if subinterpreters are not supported.""" + return unittest.skipIf(interpreters is None, + 'subinterpreters required')(meth) + + # count the number of test runs, used to create unique # strings to intern in test_intern() INTERN_NUMRUNS = 0 @@ -700,6 +709,7 @@ def __hash__(self): self.assertRaises(TypeError, sys.intern, S("abc")) + @requires_subinterpreters def test_subinterp_intern_dynamically_allocated(self): global INTERN_NUMRUNS INTERN_NUMRUNS += 1 @@ -715,6 +725,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. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy