-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathconftest.py
More file actions
46 lines (35 loc) · 1.37 KB
/
conftest.py
File metadata and controls
46 lines (35 loc) · 1.37 KB
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
"""Root conftest.py for pytest configuration."""
import os
import pytest
# Configure pytest-postgresql to find PostgreSQL binaries in CI (Debian)
def get_postgresql_bindir():
"""Find PostgreSQL binary directory."""
for version in ["16", "15", "14", "13", "12", "11"]:
path = f"/usr/lib/postgresql/{version}/bin"
if os.path.exists(path):
return path
return None
pg_bindir = get_postgresql_bindir()
if pg_bindir:
os.environ["PATH"] = f"{pg_bindir}:{os.environ.get('PATH', '')}"
def pytest_addoption(parser):
"""Add custom command line options."""
parser.addoption(
"--run-integration",
action="store_true",
default=False,
help="Run integration tests that require real services",
)
def pytest_configure(config):
"""Configure pytest with custom markers and options."""
config.addinivalue_line(
"markers", "integration: mark test as integration test requiring real services"
)
def pytest_collection_modifyitems(config, items):
"""Modify test collection based on command line options."""
if config.getoption("--run-integration"):
return
skip_integration = pytest.mark.skip(reason="need --run-integration option to run")
for item in items:
if "integration" in item.keywords or "requires_postgres" in item.keywords:
item.add_marker(skip_integration)