diff --git a/pytest_abra/pytest_abra.py b/pytest_abra/pytest_abra.py index e8c3641..21350af 100644 --- a/pytest_abra/pytest_abra.py +++ b/pytest_abra/pytest_abra.py @@ -15,26 +15,26 @@ from pytest_abra.dir_manager import DirManager from pytest_abra.env_manager import EnvFile from pytest_abra.utils import BaseUrl -# global timeout and LOCALE -LOCALE = {"Accept-Language": "de_DE"} -TIMEOUT = 20_000 -expect.set_options(timeout=TIMEOUT) - - -@pytest.fixture -def context(context: BrowserContext) -> BrowserContext: - # note: because this has the existing context fixture as an argument, it is ensured - # that the original fixture is called first and then overwritten by this custom one. - - context.set_default_timeout(TIMEOUT) - context.set_extra_http_headers(LOCALE) - return context - def pytest_addoption(parser: Parser): parser.addoption("--runner_index", action="store", type=int) parser.addoption("--output_dir", action="store", type=Path) parser.addoption("--session_id", action="store", type=str) + parser.addoption("--timeout", action="store", type=int, default=20_000) + + +@pytest.fixture +def context(context: BrowserContext, request) -> BrowserContext: + # note: because this has the existing context fixture as an argument, it is ensured + # that the original fixture is called first and then overwritten by this custom one. + + TIMEOUT = request.config.getoption("--timeout") + LOCALE = {"Accept-Language": "de_DE"} + + context.set_default_timeout(TIMEOUT) + context.set_extra_http_headers(LOCALE) + expect.set_options(timeout=TIMEOUT) + return context @pytest.fixture(scope="session")