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

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
Fix DOCString
  • Loading branch information
Oreldm committed Sep 13, 2024
commit 6f95f59d1c65343d1e9a006115fa0b67a665df52
46 changes: 45 additions & 1 deletion src/_pytest/pytester.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,12 @@ def test_something(pytester):
return self._makefile(".txt", args, kwargs)

def syspathinsert(self, path: str | os.PathLike[str] | None = None) -> None:
"""Prepend a directory to sys.path, defaults to :attr:`path`."""
"""Prepend a directory to sys.path, defaults to :attr:`path`.
This is undone automatically when this object dies at the end of each
test.
:param path:
The path.
"""
if path is None:
path = self.path

Expand Down Expand Up @@ -1372,6 +1377,31 @@ def run(
stdin: NotSetType | bytes | IO[Any] | int = CLOSE_STDIN,
env: dict[str, str] | None = None,
) -> RunResult:
"""Run a command with arguments.
Run a process using :py:class:`subprocess.Popen` saving the stdout and
stderr.
:param cmdargs:
The sequence of arguments to pass to :py:class:`subprocess.Popen`,
with path-like objects being converted to :py:class:`str`
automatically.
:param timeout:
The period in seconds after which to timeout and raise
:py:class:`Pytester.TimeoutExpired`.
:param stdin:
Optional standard input.
- If it is ``CLOSE_STDIN`` (Default), then this method calls
:py:class:`subprocess.Popen` with ``stdin=subprocess.PIPE``, and
the standard input is closed immediately after the new command is
started.
- If it is of type :py:class:`bytes`, these bytes are sent to the
standard input of the command.
- Otherwise, it is passed through to :py:class:`subprocess.Popen`.
For further information in this case, consult the document of the
``stdin`` parameter in :py:class:`subprocess.Popen`.
:type stdin: _pytest.compat.NotSetType | bytes | IO[Any] | int
:returns:
The result.
"""
__tracebackhide__ = True

cmdargs = tuple(os.fspath(arg) for arg in cmdargs)
Expand Down Expand Up @@ -1444,6 +1474,20 @@ def runpython_c(self, command: str) -> RunResult:
def runpytest_subprocess(
self, *args: str | os.PathLike[str], timeout: float | None = None
) -> RunResult:
"""Run pytest as a subprocess with given arguments.
Any plugins added to the :py:attr:`plugins` list will be added using the
``-p`` command line option. Additionally ``--basetemp`` is used to put
any temporary files and directories in a numbered directory prefixed
with "runpytest-" to not conflict with the normal numbered pytest
location for temporary files and directories.
:param args:
The sequence of arguments to pass to the pytest subprocess.
:param timeout:
The period in seconds after which to timeout and raise
:py:class:`Pytester.TimeoutExpired`.
:returns:
The result.
"""
__tracebackhide__ = True
p = make_numbered_dir(root=self.path, prefix="runpytest-", mode=0o700)
args = (f"--basetemp={p}", *args)
Expand Down