-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
[Bug Fix] Pytester.syspathinsert() has no effect when using runpytest_subprocess() . closes #10651 #12812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[Bug Fix] Pytester.syspathinsert() has no effect when using runpytest_subprocess() . closes #10651 #12812
Changes from 1 commit
1a772a3
7c775f3
0a569ca
bc0aaa1
6f95f59
c78ed4a
b88d0d3
5bb131f
f630494
4d691ea
a87a190
6b468fe
30f2ba7
7f10717
d31e435
ac930cd
994d24d
03d80d0
3d24eb3
f731aaf
2690455
6679929
080b763
1d74520
5719422
32fe1b9
2924ad0
deee731
8bd1a5b
3c88995
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
for more information, see https://pre-commit.ci
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1344,16 +1344,16 @@ | |
|
||
You probably want to use :py:meth:`run` instead. | ||
""" | ||
env = kw.pop('env', None) or os.environ.copy() | ||
env = kw.pop("env", None) or os.environ.copy() | ||
pythonpath = env.get("PYTHONPATH", "") | ||
|
||
paths_to_add = [os.getcwd()] | ||
if hasattr(self, "_syspath_prepended"): | ||
paths_to_add.insert(0, self._syspath_prepended) | ||
|
||
pythonpath = os.pathsep.join(filter(None, [*paths_to_add, pythonpath])) | ||
|
||
env["PYTHONPATH"] = pythonpath | ||
kw["env"] = env | ||
|
||
if stdin is self.CLOSE_STDIN: | ||
|
@@ -1504,24 +1504,24 @@ | |
if plugins: | ||
args = ("-p", plugins[0], *args) | ||
|
||
env = os.environ.copy() | ||
pythonpath = env.get("PYTHONPATH", "") | ||
|
||
if hasattr(self, "_syspath_prepended"): | ||
pythonpath = os.pathsep.join( | ||
filter(None, [self._syspath_prepended, pythonpath]) | ||
) | ||
|
||
env["PYTHONPATH"] = pythonpath | ||
|
||
python_executable = sys.executable | ||
pytest_command = [python_executable, "-m", "pytest"] | ||
|
||
if hasattr(self, "_syspath_prepended"): | ||
|
||
prepend_command = ( | ||
f"import sys; sys.path.insert(0, '{self._syspath_prepended}');" | ||
) | ||
pytest_command = [ | ||
python_executable, | ||
"-c", | ||
f"{prepend_command} import pytest; pytest.main({list(args)})", | ||
|
@@ -1531,7 +1531,7 @@ | |
str(arg) for arg in args | ||
) # Convert all args to strings | ||
|
||
return self.run(*pytest_command, timeout=timeout, env=env) | ||
|
||
def spawn_pytest(self, string: str, expect_timeout: float = 10.0) -> pexpect.spawn: | ||
"""Run pytest using pexpect. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add all paths from
_prepended_syspaths
at this point.