aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/pytest/py3/_pytest/pytester.py
diff options
context:
space:
mode:
authorarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-03-14 14:36:14 +0300
committerarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-03-14 14:36:14 +0300
commite55fb55efda71cea0cd9c5fdafa41af406aef5bf (patch)
tree664dd8ed9a31584f9373593983273c9de2f13e7b /contrib/python/pytest/py3/_pytest/pytester.py
parent95e3624686fdca2887aa10594ee976cfddd32e38 (diff)
downloadydb-e55fb55efda71cea0cd9c5fdafa41af406aef5bf.tar.gz
intermediate changes
ref:8379e897e1f4fa0d71bb778a7c8bc68cb5e2f5ea
Diffstat (limited to 'contrib/python/pytest/py3/_pytest/pytester.py')
-rw-r--r--contrib/python/pytest/py3/_pytest/pytester.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/contrib/python/pytest/py3/_pytest/pytester.py b/contrib/python/pytest/py3/_pytest/pytester.py
index 363a372744..8368f94412 100644
--- a/contrib/python/pytest/py3/_pytest/pytester.py
+++ b/contrib/python/pytest/py3/_pytest/pytester.py
@@ -128,7 +128,7 @@ class LsofFdLeakChecker:
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
check=True,
- universal_newlines=True,
+ text=True,
).stdout
def isopen(line: str) -> bool:
@@ -477,7 +477,9 @@ def LineMatcher_fixture(request: FixtureRequest) -> Type["LineMatcher"]:
@fixture
-def pytester(request: FixtureRequest, tmp_path_factory: TempPathFactory) -> "Pytester":
+def pytester(
+ request: FixtureRequest, tmp_path_factory: TempPathFactory, monkeypatch: MonkeyPatch
+) -> "Pytester":
"""
Facilities to write tests/configuration files, execute pytest in isolation, and match
against expected output, perfect for black-box testing of pytest plugins.
@@ -488,7 +490,7 @@ def pytester(request: FixtureRequest, tmp_path_factory: TempPathFactory) -> "Pyt
It is particularly useful for testing plugins. It is similar to the :fixture:`tmp_path`
fixture but provides methods which aid in testing pytest itself.
"""
- return Pytester(request, tmp_path_factory, _ispytest=True)
+ return Pytester(request, tmp_path_factory, monkeypatch, _ispytest=True)
@fixture
@@ -683,6 +685,7 @@ class Pytester:
self,
request: FixtureRequest,
tmp_path_factory: TempPathFactory,
+ monkeypatch: MonkeyPatch,
*,
_ispytest: bool = False,
) -> None:
@@ -706,7 +709,7 @@ class Pytester:
self._method = self._request.config.getoption("--runpytest")
self._test_tmproot = tmp_path_factory.mktemp(f"tmp-{name}", numbered=True)
- self._monkeypatch = mp = MonkeyPatch()
+ self._monkeypatch = mp = monkeypatch
mp.setenv("PYTEST_DEBUG_TEMPROOT", str(self._test_tmproot))
# Ensure no unexpected caching via tox.
mp.delenv("TOX_ENV_DIR", raising=False)
@@ -738,7 +741,6 @@ class Pytester:
self._sys_modules_snapshot.restore()
self._sys_path_snapshot.restore()
self._cwd_snapshot.restore()
- self._monkeypatch.undo()
def __take_sys_modules_snapshot(self) -> SysModulesSnapshot:
# Some zope modules used by twisted-related tests keep internal state