add timeout parameter to pytest-abra

This commit is contained in:
Daniel 2023-12-07 01:26:23 +01:00
parent 9986e46019
commit a499891fe8

View file

@ -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")