Smoke test: keep caching enabled without copying cached results.
(roundtrip, kind, state)
| 5067 | @pytest.mark.parametrize("kind", ["rule", "set"]) |
| 5068 | @pytest.mark.parametrize("state", ["disabled", "empty", "partial", "complete"]) |
| 5069 | def 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 | |
| 5097 | def _list_with_timeout(iterable, timeout=5): |