Skip to content

Commit 28a62e7

Browse files
flying-sheepnedbat
authored andcommitted
changes from code review
1 parent f682a3f commit 28a62e7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

coverage/execfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def prepare(self) -> None:
9090
This needs to happen before any importing, and without importing anything.
9191
"""
9292
path0: Optional[str]
93-
if os.environ.get('PYTHONSAFEPATH', ''):
93+
if env.PYVERSION >= (3, 11) and os.environ.get('PYTHONSAFEPATH', ''):
9494
# See https://docs.python.org/3/using/cmdline.html#cmdoption-P
9595
path0 = None
9696
elif self.as_module:

tests/test_execfile.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import py_compile
1414
import re
1515
import sys
16-
from unittest import mock
16+
from pathlib import Path
1717
from typing import Any, Iterator
1818

1919
import pytest
@@ -307,9 +307,9 @@ def test_pkg1_init(self) -> None:
307307
assert out == "pkg1.__init__: pkg1\npkg1.__init__: __main__\n"
308308
assert err == ""
309309

310-
def test_pythonpath(self, tmp_path) -> None:
311-
env = {"PYTHONSAFEPATH": "1"}
312-
with mock.patch.dict(os.environ, env), change_dir(tmp_path):
310+
def test_pythonpath(self, tmp_path: Path) -> None:
311+
self.set_environ("PYTHONSAFEPATH", "1")
312+
with change_dir(tmp_path):
313313
run_python_module(["process_test.try_execfile"])
314314
out, err = self.stdouterr()
315315
mod_globs = json.loads(out)

0 commit comments

Comments
 (0)