Skip to content

Commit

Permalink
Merge pull request #222 from dandi/fix-cache-test
Browse files Browse the repository at this point in the history
Fix bugs in test_memoize_path
  • Loading branch information
yarikoptic authored Sep 3, 2020
2 parents 97b4115 + 9ba7a22 commit b042a68
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions dandi/support/tests/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import time

from dandi.support.cache import PersistentCache
from dandi.utils import on_windows

import pytest

Expand Down Expand Up @@ -141,15 +142,18 @@ def check_new_memoread(arg, content, expect_new=False):
check_new_memoread(0, "Content")

# Check that symlinks should be dereferenced
symlink1 = str(tmp_path / (fname + ".link1"))
try:
os.symlink(fname, symlink1)
except OSError:
pass
if op.islink(fname): # hopefully would just skip Windows if not supported
ncalls = len(calls)
assert memoread(symlink1, 0) == "Content"
assert len(calls) == ncalls # no new call
if not on_windows or sys.version_info[:2] >= (3, 8):
# realpath doesn't work right on Windows on pre-3.8 Python, so skip the
# test then.
symlink1 = str(tmp_path / (fname + ".link1"))
try:
os.symlink(fname, symlink1)
except OSError:
pass
if op.islink(symlink1): # hopefully would just skip Windows if not supported
ncalls = len(calls)
assert memoread(symlink1, 0) == "Content"
assert len(calls) == ncalls # no new call

# and if we "clear", would it still work?
cache.clear()
Expand Down

0 comments on commit b042a68

Please sign in to comment.