-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Closed
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
I found at least three cases where _testinternalcapi
is just imported, we cannot do that, because other python implementation which reuse our test cases will fail on this.
-
cpython/Lib/test/test_cmd_line.py
Lines 785 to 826 in 34ddcc3
def check_pythonmalloc(self, env_var, name): code = 'import _testinternalcapi; print(_testinternalcapi.pymem_getallocatorsname())' env = dict(os.environ) env.pop('PYTHONDEVMODE', None) if env_var is not None: env['PYTHONMALLOC'] = env_var else: env.pop('PYTHONMALLOC', None) args = (sys.executable, '-c', code) proc = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, env=env) self.assertEqual(proc.stdout.rstrip(), name) self.assertEqual(proc.returncode, 0) def test_pythonmalloc(self): # Test the PYTHONMALLOC environment variable pymalloc = support.with_pymalloc() if pymalloc: default_name = 'pymalloc_debug' if support.Py_DEBUG else 'pymalloc' default_name_debug = 'pymalloc_debug' else: default_name = 'malloc_debug' if support.Py_DEBUG else 'malloc' default_name_debug = 'malloc_debug' tests = [ (None, default_name), ('debug', default_name_debug), ('malloc', 'malloc'), ('malloc_debug', 'malloc_debug'), ] if pymalloc: tests.extend(( ('pymalloc', 'pymalloc'), ('pymalloc_debug', 'pymalloc_debug'), )) for env_var, name in tests: with self.subTest(env_var=env_var, name=name): self.check_pythonmalloc(env_var, name) -
cpython/Lib/test/test_import/__init__.py
Line 25 in 34ddcc3
import _testinternalcapi -
cpython/Lib/test/test_opcache.py
Line 8 in 34ddcc3
import _testinternalcapi
There can be several options to solve this:
- Use
import _testinternalcapi
withexcept ImportError
, when some places might need it - Use
import_helper.import_module
to skip some tests where this module is required - Use
@cpython_only
decorator
Linked PRs
Metadata
Metadata
Assignees
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error