forked from pyccel/psydac
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
52 lines (43 loc) · 1.86 KB
/
Copy pathconftest.py
File metadata and controls
52 lines (43 loc) · 1.86 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
47
48
49
50
51
52
"""Root-level pytest configuration."""
import pytest
import sys
from pathlib import Path
def pytest_configure(config):
"""Register custom pytest markers and configure pytest behavior."""
# Ensure markers are registered for all pytest processes (including xdist workers)
markers_to_register = [
("mpi", "mark test as requiring MPI"),
("petsc", "mark test as requiring PETSc"),
("parallel", "mark test as parallel"),
]
for marker_name, marker_desc in markers_to_register:
# Check if already registered to avoid duplicates
existing = config.getini("markers")
if not any(marker_name in line for line in existing):
config.addinivalue_line("markers", f"{marker_name}: {marker_desc}")
def pytest_collection_modifyitems(config, items):
"""Skip tests incompatible with pytest-xdist and with missing dependencies."""
# Tests that require sympde which isn't always installed
skip_modules = {
"test_poisson.py",
"test_sum_factorization_assembly_3d.py",
"test_dirichlet_projectors.py",
"test_tensor.py",
}
items_to_remove = []
skip = pytest.mark.skip(reason="Requires optional dependency (sympde)")
for item in items:
# Skip if module is in skip list
if item.fspath.basename in skip_modules:
items_to_remove.append(item)
continue
# If running with xdist, automatically skip mpi and petsc tests
if config.pluginmanager.has_plugin("xdist"):
if item.get_closest_marker("mpi") or item.get_closest_marker("petsc"):
skip_xdist = pytest.mark.skip(
reason="Incompatible with pytest-xdist parallel execution"
)
item.add_marker(skip_xdist)
# Remove items with missing dependencies
for item in items_to_remove:
items.remove(item)