Skip to content
Draft
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1a772a3
progress
Oreldm Sep 13, 2024
7c775f3
Update Authors
Oreldm Sep 13, 2024
0a569ca
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 13, 2024
bc0aaa1
Merge branch 'main' into bug-fix-10651-syspathinsert-not-passing-to-p…
Oreldm Sep 13, 2024
6f95f59
Fix DOCString
Oreldm Sep 13, 2024
c78ed4a
Fix DOCString
Oreldm Sep 13, 2024
b88d0d3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 13, 2024
5bb131f
Fix DOCString
Oreldm Sep 13, 2024
f630494
Merge branch 'bug-fix-10651-syspathinsert-not-passing-to-pytester-sub…
Oreldm Sep 13, 2024
4d691ea
progress
Oreldm Sep 13, 2024
a87a190
progress
Oreldm Sep 13, 2024
6b468fe
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 13, 2024
30f2ba7
added bugfix.rst
Oreldm Sep 13, 2024
7f10717
Merge branch 'bug-fix-10651-syspathinsert-not-passing-to-pytester-sub…
Oreldm Sep 13, 2024
d31e435
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 13, 2024
ac930cd
progress
Oreldm Sep 13, 2024
994d24d
Merge branch 'bug-fix-10651-syspathinsert-not-passing-to-pytester-sub…
Oreldm Sep 13, 2024
03d80d0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 13, 2024
3d24eb3
progress
Oreldm Sep 13, 2024
f731aaf
Merge branch 'bug-fix-10651-syspathinsert-not-passing-to-pytester-sub…
Oreldm Sep 13, 2024
2690455
progress
Oreldm Sep 13, 2024
6679929
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 13, 2024
080b763
Fix SyntaxError in Pytester.runpytest_subprocess due to unescaped paths
Oreldm Sep 13, 2024
1d74520
Merge branch 'bug-fix-10651-syspathinsert-not-passing-to-pytester-sub…
Oreldm Sep 13, 2024
5719422
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 13, 2024
32fe1b9
Merge branch 'main' into bug-fix-10651-syspathinsert-not-passing-to-p…
Oreldm Sep 17, 2024
2924ad0
[PR Fix] Update testing/test_pytester.py remove timeout
Oreldm Sep 20, 2024
deee731
PR Fix - multiple env variable fix
Oreldm Sep 20, 2024
8bd1a5b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 20, 2024
3c88995
Merge branch 'main' into bug-fix-10651-syspathinsert-not-passing-to-p…
Oreldm Sep 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 13, 2024
commit 6679929d419aab13ef4b596165da0023d60f35e0
2 changes: 1 addition & 1 deletion src/_pytest/pytester.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", "")

Check warning on line 1348 in src/_pytest/pytester.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/pytester.py#L1347-L1348

Added lines #L1347 - L1348 were not covered by tests

paths_to_add = [os.getcwd()]

Check warning on line 1350 in src/_pytest/pytester.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/pytester.py#L1350

Added line #L1350 was not covered by tests
if hasattr(self, "_syspath_prepended"):
Copy link
Member

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.

paths_to_add.insert(0, self._syspath_prepended)

Check warning on line 1352 in src/_pytest/pytester.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/pytester.py#L1352

Added line #L1352 was not covered by tests

pythonpath = os.pathsep.join(filter(None, [*paths_to_add, pythonpath]))

Check warning on line 1354 in src/_pytest/pytester.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/pytester.py#L1354

Added line #L1354 was not covered by tests

env["PYTHONPATH"] = pythonpath

Check warning on line 1356 in src/_pytest/pytester.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/pytester.py#L1356

Added line #L1356 was not covered by tests
kw["env"] = env

if stdin is self.CLOSE_STDIN:
Expand Down Expand Up @@ -1504,24 +1504,24 @@
if plugins:
args = ("-p", plugins[0], *args)

env = os.environ.copy()
pythonpath = env.get("PYTHONPATH", "")

Check warning on line 1508 in src/_pytest/pytester.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/pytester.py#L1507-L1508

Added lines #L1507 - L1508 were not covered by tests

if hasattr(self, "_syspath_prepended"):
pythonpath = os.pathsep.join(

Check warning on line 1511 in src/_pytest/pytester.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/pytester.py#L1511

Added line #L1511 was not covered by tests
filter(None, [self._syspath_prepended, pythonpath])
)

env["PYTHONPATH"] = pythonpath

Check warning on line 1515 in src/_pytest/pytester.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/pytester.py#L1515

Added line #L1515 was not covered by tests

python_executable = sys.executable
pytest_command = [python_executable, "-m", "pytest"]

Check warning on line 1518 in src/_pytest/pytester.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/pytester.py#L1517-L1518

Added lines #L1517 - L1518 were not covered by tests

if hasattr(self, "_syspath_prepended"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we setting sys.path and configuring PYTHONPATH? Isn't sufficient to only configure PYTHONPATH?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I don't think we need to modify runpytest_subprocess at all, given we are already configuring PYTHONPATH in popen?

prepend_command = (

Check warning on line 1521 in src/_pytest/pytester.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/pytester.py#L1521

Added line #L1521 was not covered by tests
f"import sys; sys.path.insert(0, '{self._syspath_prepended}');"
)
pytest_command = [

Check warning on line 1524 in src/_pytest/pytester.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/pytester.py#L1524

Added line #L1524 was not covered by tests
python_executable,
"-c",
f"{prepend_command} import pytest; pytest.main({list(args)})",
Expand All @@ -1531,7 +1531,7 @@
str(arg) for arg in args
) # Convert all args to strings

return self.run(*pytest_command, timeout=timeout, env=env)

Check warning on line 1534 in src/_pytest/pytester.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/pytester.py#L1534

Added line #L1534 was not covered by tests

def spawn_pytest(self, string: str, expect_timeout: float = 10.0) -> pexpect.spawn:
"""Run pytest using pexpect.
Expand Down
Loading