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.

fix: deflake test_imported_app_has_prefixed_setup_cell (#7824)

Akshay Agrawalf0d197e08912
diff --git a/.github/workflows/test_be.yaml b/.github/workflows/test_be.yaml
index a98efcfb6f..de5adf27d5 100644
--- a/.github/workflows/test_be.yaml
+++ b/.github/workflows/test_be.yaml
@@ -102,7 +102,7 @@ jobs:
if: ${{ needs.changes.outputs.backend == 'true' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'test-all')) }}
name: ${{ matrix.os }} / Py ${{ matrix.python-version }} / ${{ matrix.dependencies }} deps
runs-on: ${{ matrix.os }}
- timeout-minutes: 20
+ timeout-minutes: 25
defaults:
run:
shell: bash
diff --git a/tests/_ast/test_app.py b/tests/_ast/test_app.py
index d0c44ff37f..7d50efc3dd 100644
--- a/tests/_ast/test_app.py
+++ b/tests/_ast/test_app.py
@@ -1573,14 +1573,20 @@ class TestAppComposition:
"""
await k.run([
exec_req.get("""
- # Import in kernel context
- from tests._ast.app_data.notebook_filename import app
+ # Import in kernel context; the prefix the app gets
+ # depends on whether it was first imported in a kernel context,
+ # so we reload it in case notebook_filename was loaded elsewhere
+ # in tests
+ import tests._ast.app_data.notebook_filename as mod
+ import importlib
+ # This forces the app object to be constructed in the runtime context
+ importlib.reload(mod)
+ app = mod.app
""")
])
assert not k.errors
nb_app = k.globals["app"]
cell_ids = list(InternalApp(nb_app).cell_manager.cell_ids())
- all_prefixed = all(is_external_cell_id(cid) for cid in cell_ids)
setup_cell_ids = [cid for cid in cell_ids if cid.endswith(SETUP_CELL_NAME)]
assert len(setup_cell_ids) == 1
assert is_external_cell_id(setup_cell_ids[0])