Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

flaky: add warning for flaky test opposed to failure (#3674)

Dylan Madisetti92a89a1bd505
diff --git a/tests/_save/test_cache.py b/tests/_save/test_cache.py
index 521ab912e8..33a9f69783 100644
--- a/tests/_save/test_cache.py
+++ b/tests/_save/test_cache.py
@@ -777,9 +777,11 @@ class TestCacheDecorator:
# Cache hit value may be flaky depending on when state is evicted from
# the registry. The actual cache hit is less important than caching
# occurring in the first place.
- # 2 * 9 + 2
+ # NB. 20 = 2 * 9 + 2
if k.globals["fib"].hits in (9, 18):
- warnings.warn("Known flaky edge case for cache.", stacklevel=1)
+ warnings.warn(
+ "Known flaky edge case for cache with state dep.", stacklevel=1
+ )
else:
assert k.globals["fib"].hits == 20
@@ -879,7 +881,14 @@ class TestCacheDecorator:
)
assert not k.stderr.messages, k.stderr
assert not k.stdout.messages, k.stdout
- assert k.globals["fib"].hits == 10 + 3
+ # Throw a warning for flake edge case where cache is evicted earlier
+ # than expected.
+ if k.globals["fib"].hits in (10,):
+ warnings.warn(
+ "Known flaky edge case for cache rerun.", stacklevel=1
+ )
+ else:
+ assert k.globals["fib"].hits == 10 + 3
async def test_full_scope_utilized(
self, k: Kernel, exec_req: ExecReqProvider