flaky test_memoize_path_dir ?
- Dominant language
- Python
- Stars
- 2
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
Fresh run https://github.com/con/fscacher/runs/4440200422?check_suite_focus=true failed on Mac
```
____________________________ test_memoize_path_dir _____________________________
cache =
tmp_path = PosixPath('/private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pytest-of-runner/pytest-0/test_memoize_path_dir0')
def test_memoize_path_dir(cache, tmp_path):
calls = []
@cache.memoize_path
def memoread(path, arg, kwarg=None):
calls.append([path, arg, kwarg])
total_size = 0
with os.scandir(path) as entries:
for e in entries:
if e.is_file():
total_size += e.stat().st_size
return total_size
def check_new_memoread(arg, content, expect_new=False):
ncalls = len(calls)
assert memoread(path, arg) == content
assert len(calls) == ncalls + 1
assert memoread(path, arg) == content
assert len(calls) == ncalls + 1 + int(expect_new)
fname = "foo"
path = tmp_path / fname
with pytest.raises(IOError):
memoread(path, 0)
# and again
with pytest.raises(IOError):
memoread(path, 0)
assert len(calls) == 2
path.mkdir()
(path / "a.txt").write_text("Alpha")
(path / "b.txt").write_text("Beta")
t0 = time.time()
try:
# unless this computer is too slow -- there should be less than
# cache._min_dtime between our creating the file and testing,
# so we would force a direct read:
> check_new_memoread(0, 9, True)
.tox/py/lib/python3.9/site-packages/fscacher/tests/test_cache.py:204:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
arg = 0, content = 9, expect_new = True
def check_new_memoread(arg, content, expect_new=False):
ncalls = len(calls)
assert memoread(path, arg) == content
assert len(calls) == ncalls + 1
assert memoread(path, arg) == content
> assert len(calls) == ncalls + 1 + int(expect_new)
E AssertionError: assert 3 == ((2 + 1) + 1)
E + where 3 = len([['/private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pytest-of-runner/pytest-0/test_memoize_path_dir0/foo', 0, ...rivate/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pytest-of-runner/pytest-0/test_memoize_path_dir0/foo', 0, None]])
E + and 1 = int(True)
.tox/py/lib/python3.9/site-packages/fscacher/tests/test_cache.py:183: AssertionError
```
although was all green before AFAIK.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with fscacher/tests/test_cache.py, specifically test_memoize_path_dir and its check_new_memoread helper, then run the test on a Mac or inspect the linked CI failure. Compare the _min_dtime timing assumption with the observed call count; done means the test reliably reflects the intended memoization behavior without intermittent failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100