add optional `new_path` argument to `Pytester.chdir`

This commit is contained in:
DetachHead 2024-02-08 20:04:36 +10:00 committed by GitHub
parent 9454fc38d3
commit 86a60250c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 1 deletions

View File

@ -750,11 +750,16 @@ class Pytester:
self._request.addfinalizer(reprec.finish_recording) self._request.addfinalizer(reprec.finish_recording)
return reprec return reprec
def chdir(self) -> None: def chdir(self, new_path: Optional[Path] = None) -> None:
"""Cd into the temporary directory. """Cd into the temporary directory.
This is done automatically upon instantiation. This is done automatically upon instantiation.
:param new_path:
Optionally specify a different path to cd into
""" """
if new_path:
self._path = new_path
self._monkeypatch.chdir(self.path) self._monkeypatch.chdir(self.path)
def _makefile( def _makefile(