MCPcopy Create free account
hub / github.com/dateutil/dateutil / test_roundtrip_cache_setting_smoke

Function test_roundtrip_cache_setting_smoke

tests/test_rrule.py:5069–5094  ·  view source on GitHub ↗

Smoke test: keep caching enabled without copying cached results.

(roundtrip, kind, state)

Source from the content-addressed store, hash-verified

5067@pytest.mark.parametrize("kind", ["rule", "set"])
5068@pytest.mark.parametrize("state", ["disabled", "empty", "partial", "complete"])
5069def test_roundtrip_cache_setting_smoke(roundtrip, kind, state):
5070 """Smoke test: keep caching enabled without copying cached results."""
5071 # TODO: Use a public interface for the cache setting when one is available.
5072 cache = state != "disabled"
5073 original = rrule(DAILY, dtstart=datetime(2024, 1, 1), count=25, cache=cache)
5074 if kind == "set":
5075 result = rruleset(cache=cache)
5076 result.rrule(original)
5077 original = result
5078 if state == "partial":
5079 next(iter(original))
5080 elif state == "complete":
5081 list(original)
5082 original_cache = None if not cache else list(original._cache)
5083
5084 restored = roundtrip(original)
5085 if cache:
5086 assert restored._cache == []
5087 assert restored._len is None
5088 assert not restored._cache_complete
5089 assert restored._cache_lock is not original._cache_lock
5090 assert restored._cache_gen is not original._cache_gen
5091 else:
5092 assert restored._cache is None
5093 assert original._cache == original_cache
5094 assert list(restored) == list(original)
5095
5096
5097def _list_with_timeout(iterable, timeout=5):

Callers

nothing calls this directly

Calls 4

rruleClass · 0.90
rrulesetClass · 0.90
roundtripFunction · 0.85
rruleMethod · 0.80

Tested by

no test coverage detected