Fix -Xfrozen_modules warnings in test runs on Python 3.11 and 3.12

This commit is contained in:
Pavel Minaev 2023-08-16 15:26:46 -07:00 committed by Pavel Minaev
parent db3452db32
commit 83baa6d302
2 changed files with 14 additions and 8 deletions

View file

@ -350,15 +350,19 @@ class Session(object):
env.pop("COV_CORE_SOURCE", None)
return env
def _make_python_cmdline(self, exe, *args):
cmd = [exe]
if sys.version_info[:2] >= (3, 11):
cmd += ["-X", "frozen_modules=off"]
cmd += [str(s.strpath if isinstance(s, py.path.local) else s) for s in args]
return cmd
def spawn_debuggee(self, args, cwd=None, exe=sys.executable, setup=None):
assert self.debuggee is None
assert not len(self.captured_output - {"stdout", "stderr"})
args = [exe] + [
str(s.strpath if isinstance(s, py.path.local) else s) for s in args
]
args = self._make_python_cmdline(exe, *args)
cwd = cwd.strpath if isinstance(cwd, py.path.local) else cwd
env = self._make_env(self.spawn_debuggee.env, codecov=False)
@ -406,7 +410,7 @@ class Session(object):
assert self.adapter is None
assert self.channel is None
args = [sys.executable, os.path.dirname(debugpy.adapter.__file__)] + list(args)
args = self._make_python_cmdline(sys.executable, os.path.dirname(debugpy.adapter.__file__), *args)
env = self._make_env(self.spawn_adapter.env)
log.info(

View file

@ -1,5 +1,5 @@
[tox]
envlist = py{37,38,39,310}{,-cov}
envlist = py{37,38,39,310,311,312}{,-cov}
[testenv]
deps = -rtests/requirements.txt
@ -7,5 +7,7 @@ passenv = DEBUGPY_LOG_DIR,DEBUGPY_TESTS_FULL
setenv =
DEBUGPY_TEST=1
commands =
!cov: pytest {posargs}
cov: pytest --cov --cov-append --cov-config=.coveragerc {posargs}
!py312-!cov: python -m pytest {posargs}
!py312-cov: python -m pytest --cov --cov-append --cov-config=.coveragerc {posargs}
py312-!cov: python -Xfrozen_modules=off -m pytest {posargs}
py312-cov: python -Xfrozen_modules=off -m pytest --cov --cov-append --cov-config=.coveragerc {posargs}