Refactor tmpdir to use setdefault
This commit is contained in:
parent
ca2cc3da2a
commit
5959e979d5
|
@ -13,6 +13,7 @@ from typing import Union
|
||||||
|
|
||||||
from _pytest.nodes import Item
|
from _pytest.nodes import Item
|
||||||
from _pytest.stash import StashKey
|
from _pytest.stash import StashKey
|
||||||
|
from pytest import CollectReport
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing_extensions import Literal
|
from typing_extensions import Literal
|
||||||
|
@ -318,9 +319,7 @@ def pytest_sessionfinish(session, exitstatus: Union[int, ExitCode]):
|
||||||
@hookimpl(tryfirst=True, hookwrapper=True)
|
@hookimpl(tryfirst=True, hookwrapper=True)
|
||||||
def pytest_runtest_makereport(item: Item, call):
|
def pytest_runtest_makereport(item: Item, call):
|
||||||
outcome = yield
|
outcome = yield
|
||||||
result = outcome.get_result()
|
result: CollectReport = outcome.get_result()
|
||||||
|
|
||||||
if tmppath_result_key not in item.stash:
|
empty: Dict[str, bool] = {}
|
||||||
item.stash[tmppath_result_key] = {result.when: result.passed}
|
item.stash.setdefault(tmppath_result_key, empty)[result.when] = result.passed
|
||||||
else:
|
|
||||||
item.stash[tmppath_result_key][result.when] = result.passed
|
|
||||||
|
|
Loading…
Reference in New Issue