()
| 22 | |
| 23 | |
| 24 | def test_cache(): |
| 25 | c = cachey.Cache(10000) |
| 26 | cc = Cache(c) |
| 27 | |
| 28 | with cc: |
| 29 | assert get({"x": (inc, 1)}, "x") == 2 |
| 30 | |
| 31 | assert flag == [1] |
| 32 | assert c.data["x"] == 2 |
| 33 | |
| 34 | assert not cc.starttimes |
| 35 | assert not cc.durations |
| 36 | |
| 37 | while flag: |
| 38 | flag.pop() |
| 39 | dsk = {"x": (inc, 1), "y": (inc, 2), "z": (add, "x", "y")} |
| 40 | with cc: |
| 41 | assert get(dsk, "z") == 5 |
| 42 | |
| 43 | assert flag == [2] # no x present |
| 44 | |
| 45 | assert not Callback.active |
| 46 | |
| 47 | |
| 48 | def test_cache_with_number(): |