-
Notifications
You must be signed in to change notification settings - Fork 4
/
conftest.py
51 lines (35 loc) · 1.13 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
51
import pytest
from pytest_socket import disable_socket
from geminiportal.app import app as _app
def pytest_addoption(parser):
parser.addoption(
"--run-integration",
action="store_true",
default=False,
help="run integration tests",
)
def pytest_configure(config):
config.addinivalue_line("markers", "integration: mark test as integration")
def pytest_runtest_setup(item):
if "integration" not in item.keywords:
disable_socket(allow_unix_socket=True)
def pytest_collection_modifyitems(config, items):
if config.getoption("--run-integration"):
# Collect all tests, including integration tests
return
skip_integration = pytest.mark.skip(reason="integration test")
for item in items:
if "integration" in item.keywords:
item.add_marker(skip_integration)
@pytest.fixture()
def app():
_app.config["DEBUG"] = True
_app.config["TESTING"] = True
_app.config["SERVER_NAME"] = "portal.mozz.us"
return _app
@pytest.fixture()
def client(app):
return app.test_client()
@pytest.fixture()
def runner(app):
return app.test_cli_runner()