Files
mvdbeek 1f5bed69ce Tear down selenium driver when a subclass setUp fails
Subclasses override setUp and do fallible work after super().setUp() has
allocated the driver: on newer branches a tool shed install, API fixture
creation and an execute_script call. pytest skips teardown_method when
setup_method raises, so the driver leaked and, with Playwright, every
later test on the worker failed with "Sync API inside the asyncio loop".

Wrap setup_method, which calls the most derived setUp, in the
tear-down-on-error guard in both Selenium base test classes.
2026-11-23 12:47:08 +01:00

41 lines
1.1 KiB
Python

from typing import TYPE_CHECKING
from galaxy_test.driver import integration_util
from galaxy_test.selenium import framework
if TYPE_CHECKING:
from galaxy_test.selenium.framework import SeleniumSessionDatasetPopulator
selenium_test = framework.selenium_test
managed_history = framework.managed_history
class SeleniumIntegrationTestCase(
integration_util.IntegrationTestCase, framework.TestWithSeleniumMixin, framework.UsesLibraryAssertions
):
dataset_populator: "SeleniumSessionDatasetPopulator"
def setup_method(self):
# pytest skips teardown_method when setup_method raises, so tear the
# driver down here when a subclass setUp fails after allocating it.
with self._tear_down_driver_on_error():
super().setup_method()
def setUp(self):
super().setUp()
self.setup_selenium()
def tearDown(self):
self.tear_down_selenium()
super().tearDown()
def restart(self, handle_reconfig=None):
super().restart(handle_reconfig=handle_reconfig)
self.reset_driver_and_session()
__all__ = (
"selenium_test",
"SeleniumIntegrationTestCase",
)