Skip to content

Commit 2fcaa79

Browse files
committed
Show cache age instead of update date
1 parent 1f7a151 commit 2fcaa79

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/_pytest/stepwise.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import dataclasses
44
from datetime import datetime
5+
from datetime import timedelta
56
from typing import Any
67
from typing import TYPE_CHECKING
78

@@ -159,8 +160,11 @@ def pytest_collection_modifyitems(
159160
if failed_index is None:
160161
self.report_status.append("previously failed test not found, not skipping.")
161162
else:
163+
cache_age = datetime.now() - self.cached_info.last_cache_date
164+
# Round up to avoid showing microseconds.
165+
cache_age = timedelta(seconds=int(cache_age.total_seconds()))
162166
self.report_status.append(
163-
f"skipping {failed_index} already passed items (cache from {self.cached_info.last_cache_date},"
167+
f"skipping {failed_index} already passed items (cache from {cache_age} ago,"
164168
f" use --sw-reset to discard)."
165169
)
166170
deselected = items[:failed_index]

testing/test_stepwise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def test_data(expected):
117117
result = pytester.runpytest("-v", "--stepwise")
118118
result.stdout.fnmatch_lines(
119119
[
120-
"stepwise: skipping 4 already passed items (cache from *, use --sw-reset to discard).",
120+
"stepwise: skipping 4 already passed items (cache from * ago, use --sw-reset to discard).",
121121
"*1 failed, 4 deselected*",
122122
]
123123
)

0 commit comments

Comments
 (0)