aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-03-01 16:36:48 +0100
committerWojtek Kosior <koszko@koszko.org>2022-03-04 16:13:39 +0100
commit241f58b66f5a245c3dd85101dee052bba358bbc8 (patch)
tree3c122ede420f3862047a6ee2aab348b9cea9a6a3
parent57ce414ca81682a71288018a4d9001604002ec23 (diff)
downloadbrowser-extension-241f58b66f5a245c3dd85101dee052bba358bbc8.tar.gz
browser-extension-241f58b66f5a245c3dd85101dee052bba358bbc8.zip
stop `haketilo()` fixture cleanup from closing last browser window
-rw-r--r--test/haketilo_test/conftest.py20
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 = '''\
/*