core/cachew: special handling for None in order to preserve cache_dir() path
+ add 'suffix' argument for more straighforward logic
This commit is contained in:
parent
da3c1c9b74
commit
9afe1811a5
4 changed files with 59 additions and 3 deletions
|
@ -120,3 +120,22 @@ def test_cachew() -> None:
|
|||
|
||||
assert list(cf()) == [1, 2, 3]
|
||||
assert called == cc
|
||||
|
||||
|
||||
def test_cachew_dir_none() -> None:
|
||||
from cachew import settings
|
||||
settings.ENABLE = True # by default it's off in tests (see conftest.py)
|
||||
|
||||
from my.core.cachew import cache_dir
|
||||
from my.core.common import mcachew
|
||||
from my.core.core_config import _reset_config as reset
|
||||
with reset() as cc:
|
||||
cc.cache_dir = None
|
||||
called = 0
|
||||
@mcachew(cache_path=cache_dir() / 'ctest')
|
||||
def cf() -> List[int]:
|
||||
nonlocal called
|
||||
called += 1
|
||||
return [called, called, called]
|
||||
assert list(cf()) == [1, 1, 1]
|
||||
assert list(cf()) == [2, 2, 2]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue