From f72b02db7b3863534851e547f21515c0fa886959 Mon Sep 17 00:00:00 2001 From: "Maarten A. Breddels" Date: Wed, 30 Aug 2023 12:41:47 +0200 Subject: [PATCH] test: make more robust by closing previous page sessions --- solara/test/pytest_plugin.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/solara/test/pytest_plugin.py b/solara/test/pytest_plugin.py index 8a0709251..e23b7f580 100644 --- a/solara/test/pytest_plugin.py +++ b/solara/test/pytest_plugin.py @@ -169,6 +169,15 @@ def SyncWrapper(): def solara_test(solara_server, solara_app, page_session: "playwright.sync_api.Page"): global run_calls with solara_app("solara.test.pytest_plugin:SyncWrapper"): + # a currently open page will try to connect to solara, creating a + # new context, so we navigate away first, then close all contexts + page_session.goto("about:blank") + for key in list(solara.server.app.contexts): + try: + solara.server.app.contexts[key].close() + except: # noqa + pass + assert len(solara.server.app.contexts) == 0 page_session.goto(solara_server.base_url) run_event.wait() assert run_calls == 1