Why
tests/streamlit/test_mc_page.py:246-251 reloads streamlit_app.* modules while streamlit is stubbed; tests/baseline/test_streamlit_smoke.py:37-47 documents that monkeypatch does not restore reloaded page modules. This is a latent flake: AppTest smoke tests can render into a dummy and pass vacuously unless modules are evicted manually.
Scope
Shared pytest fixture/autouse teardown that removes streamlit_app entries from sys.modules after DummyStreamlit tests. Add an order-regression test that runs MC stub test then AppTest smoke without manual eviction.
Implementation Notes
- Implement fixture in
tests/streamlit/conftest.py or tests/conftest.py.
- Reuse eviction list logic from
tests/baseline/test_streamlit_smoke.py:44-47.
- Do not remove DummyStreamlit unit tests; they remain valid for fast widget logic checks.
- Coordinate with any existing
tests/baseline/harness.py utilities.
Tasks
Acceptance Criteria
Non-Goals
- Migrating all Streamlit unit tests to AppTest
- Fixing numpy collection errors in
tests/streamlit/test_mc_plots.py
Scaffold-only completion does NOT count: a fixture that evicts modules but has no regression test proving AppTest still sees real Streamlit is a failure of this issue.
Why
tests/streamlit/test_mc_page.py:246-251reloadsstreamlit_app.*modules whilestreamlitis stubbed;tests/baseline/test_streamlit_smoke.py:37-47documents thatmonkeypatchdoes not restore reloaded page modules. This is a latent flake: AppTest smoke tests can render into a dummy and pass vacuously unless modules are evicted manually.Scope
Shared pytest fixture/autouse teardown that removes
streamlit_appentries fromsys.modulesafter DummyStreamlit tests. Add an order-regression test that runs MC stub test then AppTest smoke without manual eviction.Implementation Notes
tests/streamlit/conftest.pyortests/conftest.py.tests/baseline/test_streamlit_smoke.py:44-47.tests/baseline/harness.pyutilities.Tasks
tests/streamlit/conftest.pyevictingstreamlit_app*fromsys.modulestest_stub_reload_does_not_break_apptestintests/baseline/test_streamlit_smoke.pythat chains_load_page+_run_page_load_pagehelper or duplicate minimal stub install in the regression test only if import cycles forbid sharingAcceptance Criteria
pytest tests/baseline/test_streamlit_smoke.py tests/streamlit/test_mc_page.py -qpassestests/streamlit/conftest.pyand confirmtest_stub_reload_does_not_break_apptestfails; revertNon-Goals
tests/streamlit/test_mc_plots.pyScaffold-only completion does NOT count: a fixture that evicts modules but has no regression test proving AppTest still sees real Streamlit is a failure of this issue.