aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/pytest/py3/_pytest/tmpdir.py
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2025-05-05 12:31:52 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2025-05-05 12:41:33 +0300
commit6ff49ec58061f642c3a2f83c61eba12820787dfc (patch)
treec733ec9bdb15ed280080d31dea8725bfec717acd /contrib/python/pytest/py3/_pytest/tmpdir.py
parenteefca8305c6a545cc6b16dca3eb0d91dcef2adcd (diff)
downloadydb-6ff49ec58061f642c3a2f83c61eba12820787dfc.tar.gz
Intermediate changes
commit_hash:8b3bb826b17db8329ed1221f545c0645f12c552d
Diffstat (limited to 'contrib/python/pytest/py3/_pytest/tmpdir.py')
-rw-r--r--contrib/python/pytest/py3/_pytest/tmpdir.py51
1 files changed, 24 insertions, 27 deletions
diff --git a/contrib/python/pytest/py3/_pytest/tmpdir.py b/contrib/python/pytest/py3/_pytest/tmpdir.py
index 3cc2bace55b..986824ccb72 100644
--- a/contrib/python/pytest/py3/_pytest/tmpdir.py
+++ b/contrib/python/pytest/py3/_pytest/tmpdir.py
@@ -1,44 +1,40 @@
"""Support for providing temporary directories to test functions."""
+
import dataclasses
import os
-import re
-import tempfile
from pathlib import Path
+import re
from shutil import rmtree
+import tempfile
from typing import Any
from typing import Dict
+from typing import final
from typing import Generator
+from typing import Literal
from typing import Optional
-from typing import TYPE_CHECKING
from typing import Union
-from _pytest.nodes import Item
-from _pytest.reports import CollectReport
-from _pytest.stash import StashKey
-
-if TYPE_CHECKING:
- from typing_extensions import Literal
-
- RetentionType = Literal["all", "failed", "none"]
-
-
-from _pytest.config.argparsing import Parser
-
+from .pathlib import cleanup_dead_symlinks
from .pathlib import LOCK_TIMEOUT
from .pathlib import make_numbered_dir
from .pathlib import make_numbered_dir_with_cleanup
from .pathlib import rm_rf
-from .pathlib import cleanup_dead_symlinks
-from _pytest.compat import final, get_user_id
+from _pytest.compat import get_user_id
from _pytest.config import Config
from _pytest.config import ExitCode
from _pytest.config import hookimpl
+from _pytest.config.argparsing import Parser
from _pytest.deprecated import check_ispytest
from _pytest.fixtures import fixture
from _pytest.fixtures import FixtureRequest
from _pytest.monkeypatch import MonkeyPatch
+from _pytest.nodes import Item
+from _pytest.reports import TestReport
+from _pytest.stash import StashKey
+
tmppath_result_key = StashKey[Dict[str, bool]]()
+RetentionType = Literal["all", "failed", "none"]
@final
@@ -54,13 +50,13 @@ class TempPathFactory:
_trace: Any
_basetemp: Optional[Path]
_retention_count: int
- _retention_policy: "RetentionType"
+ _retention_policy: RetentionType
def __init__(
self,
given_basetemp: Optional[Path],
retention_count: int,
- retention_policy: "RetentionType",
+ retention_policy: RetentionType,
trace,
basetemp: Optional[Path] = None,
*,
@@ -209,7 +205,7 @@ def get_user() -> Optional[str]:
import getpass
return getpass.getuser()
- except (ImportError, KeyError):
+ except (ImportError, OSError, KeyError):
return None
@@ -273,7 +269,6 @@ def tmp_path(
The returned object is a :class:`pathlib.Path` object.
"""
-
path = _mk_tmp(request, tmp_path_factory)
yield path
@@ -315,10 +310,12 @@ def pytest_sessionfinish(session, exitstatus: Union[int, ExitCode]):
cleanup_dead_symlinks(basetemp)
-@hookimpl(tryfirst=True, hookwrapper=True)
-def pytest_runtest_makereport(item: Item, call):
- outcome = yield
- result: CollectReport = outcome.get_result()
-
+@hookimpl(wrapper=True, tryfirst=True)
+def pytest_runtest_makereport(
+ item: Item, call
+) -> Generator[None, TestReport, TestReport]:
+ rep = yield
+ assert rep.when is not None
empty: Dict[str, bool] = {}
- item.stash.setdefault(tmppath_result_key, empty)[result.when] = result.passed
+ item.stash.setdefault(tmppath_result_key, empty)[rep.when] = rep.passed
+ return rep