forked from nivlab/nivturk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
50 lines (42 loc) · 1.54 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import pytest
def pytest_addoption(parser):
parser.addoption(
"--server", action="store_true", default=False,
help="include verification of server-side values, only possible if "
"run in the directory serving the website"
)
parser.addoption(
"--loadtest", action="store_true", default=False,
help="disable redirection to proflific pages,"
"for use during load testing"
)
parser.addoption(
"--url", action="store", default="127.0.0.1:8000",
help="url for the tests to run against"
)
parser.addoption(
"--protocol", action="store", default="https", choices=["https", "http"],
help="protocol to preprend to url for the tests to run against"
)
parser.addoption(
"--ignore-https-errors", action="store_true", default=False,
help="ignore https errors to enable testing with self-signed cert"
)
@pytest.fixture
def server(request):
return request.config.getoption("--server")
@pytest.fixture
def url(request):
return f'{request.config.getoption("--protocol")}://{request.config.getoption("--url")}/'
@pytest.fixture()
def loadtest(request):
return request.config.getoption("--loadtest")
@pytest.fixture()
def ignore_https_errors(request):
return request.config.getoption("--ignore-https-errors")
@pytest.fixture(scope="session")
def browser_context_args(request, browser_context_args):
return {
**browser_context_args,
"ignore_https_errors": request.config.getoption("--ignore-https-errors")
}