Skip to content

Commit

Permalink
Show cache age instead of update date
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus committed Jan 15, 2025
1 parent 1f7a151 commit 2fcaa79
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/_pytest/stepwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import dataclasses
from datetime import datetime
from datetime import timedelta
from typing import Any
from typing import TYPE_CHECKING

Expand Down Expand Up @@ -159,8 +160,11 @@ def pytest_collection_modifyitems(
if failed_index is None:
self.report_status.append("previously failed test not found, not skipping.")
else:
cache_age = datetime.now() - self.cached_info.last_cache_date
# Round up to avoid showing microseconds.
cache_age = timedelta(seconds=int(cache_age.total_seconds()))
self.report_status.append(
f"skipping {failed_index} already passed items (cache from {self.cached_info.last_cache_date},"
f"skipping {failed_index} already passed items (cache from {cache_age} ago,"
f" use --sw-reset to discard)."
)
deselected = items[:failed_index]
Expand Down
2 changes: 1 addition & 1 deletion testing/test_stepwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_data(expected):
result = pytester.runpytest("-v", "--stepwise")
result.stdout.fnmatch_lines(
[
"stepwise: skipping 4 already passed items (cache from *, use --sw-reset to discard).",
"stepwise: skipping 4 already passed items (cache from * ago, use --sw-reset to discard).",
"*1 failed, 4 deselected*",
]
)
Expand Down

0 comments on commit 2fcaa79

Please sign in to comment.