diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-03-01 16:36:48 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-03-04 16:13:39 +0100 |
commit | 241f58b66f5a245c3dd85101dee052bba358bbc8 (patch) | |
tree | 3c122ede420f3862047a6ee2aab348b9cea9a6a3 /test | |
parent | 57ce414ca81682a71288018a4d9001604002ec23 (diff) | |
download | browser-extension-241f58b66f5a245c3dd85101dee052bba358bbc8.tar.gz browser-extension-241f58b66f5a245c3dd85101dee052bba358bbc8.zip |
stop `haketilo()` fixture cleanup from closing last browser window
Diffstat (limited to 'test')
-rw-r--r-- | test/haketilo_test/conftest.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/test/haketilo_test/conftest.py b/test/haketilo_test/conftest.py index 834f026..eaee910 100644 --- a/test/haketilo_test/conftest.py +++ b/test/haketilo_test/conftest.py @@ -74,6 +74,16 @@ def driver(proxy, _driver, request): _driver.implicitly_wait(0) yield _driver +def safe_uninstall_addon(driver, addon_id): + """ + Unloading an extension might cause its windows to vanish. Make sure there's + at least one window navigated to some other page before uninstalling the + addon. Otherwise, we could be left with a windowless browser :c + """ + driver.switch_to.window(driver.window_handles[-1]) + driver.get('https://gotmyowndoma.in/') + driver.uninstall_addon(addon_id) + @pytest.fixture() def webextension(driver, request): ext_data = request.node.get_closest_marker('ext_data') @@ -97,13 +107,7 @@ def webextension(driver, request): yield - # Unloading an extension might cause its windows to vanish. Make sure - # there's at least one window navigated to some other page before - # uninstalling the addon. Otherwise, we could be left with a windowless - # browser :c - driver.switch_to.window(driver.window_handles[-1]) - driver.get('https://gotmyowndoma.in/') - driver.uninstall_addon(addon_id) + safe_uninstall_addon(driver, addon_id) ext_path.unlink() @pytest.fixture() @@ -113,7 +117,7 @@ def haketilo(driver): yield - driver.uninstall_addon(addon_id) + safe_uninstall_addon(driver, addon_id) script_injector_script = '''\ /* |