Skip to content

Commit

Permalink
Test memoize.skip()
Browse files Browse the repository at this point in the history
  • Loading branch information
Suor committed Jun 23, 2024
1 parent 859056d commit 207a781
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ def mul(x, by=1):
assert calls == [(0, 1), (1, 1), (0, 1), (1, 1)]


def test_memoize_skip():
@memoize
def inc(x):
calls.append(x)
if x == 2:
raise memoize.skip
if x == 3:
raise memoize.skip(42)
return x + 1

calls = []
assert inc(1) == 2
assert inc(2) is None
assert inc(2) is None
assert inc(3) == 42
assert inc(3) == 42
assert calls == [1, 2, 2, 3, 3]


def test_memoize_memory():
@memoize
def inc(x):
Expand Down

0 comments on commit 207a781

Please sign in to comment.