summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 = '''\
/*