Skip to content

Commit

Permalink
ENH: add logging information on when check in test_memoize_path_dir f…
Browse files Browse the repository at this point in the history
…ails
  • Loading branch information
yarikoptic committed Nov 18, 2024
1 parent 33dd183 commit 5c56ff4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/fscacher/tests/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
on_windows = platform_system == "windows"
on_pypy = platform.python_implementation().lower() == "pypy"

import logging
lgr = logging.getLogger(__name__)


@pytest.fixture(autouse=True)
def capture_all_logs(caplog):
Expand Down Expand Up @@ -207,7 +210,12 @@ def check_new_memoread(arg, content, expect_new=False):
except AssertionError: # pragma: no cover
# if computer is indeed slow (happens on shared CIs) we might fail
# because distance is too short
if time.time() - t0 < cache._min_dtime:
t_now = time.time()
if t_now - t0 < cache._min_dtime:
# Log more information to troubleshoot
lgr.error(f"Failing test with t0={t0}, t_now={t_now}, dt={t_now - t0}, min_dtime={cache._min_dtime}")
for p in ("a.txt", "b.txt"):
lgr.error(f" {p}: {op.getmtime(path / p)}")
raise # if we were quick but still failed -- legit
assert calls[-1] == [path, 0, None]

Expand Down

0 comments on commit 5c56ff4

Please sign in to comment.