Skip to content

Commit 747da4b

Browse files
Review suggestions
1 parent 4988362 commit 747da4b

File tree

4 files changed

+48
-21
lines changed

4 files changed

+48
-21
lines changed

.github/actions/run_tests/action.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,5 @@ runs:
4646
pip list
4747
cd tests
4848
coverage run --rcfile=${{ inputs.coverage_config }} testing_main.py
49-
coverage html
50-
coverage report
51-
coverage-badge -o htmlcov/coverage.svg
49+
cd ..
5250
pytest

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ CI-CD = [
6060
[tool.pytest.ini_options]
6161
addopts = "-p pytest_cov --cov-report=term --cov-report=html --cov-fail-under=30 --cov=meshpy/ --cov=tutorial/ --cov-append"
6262
markers = [
63-
"fourc_arborx: tests in combination with 4C and ArborX",
63+
"fourc: tests in combination with 4C",
64+
"arborx: tests in combination with ArborX",
6465
"cubitpy: tests in combination with CubitPy",
6566
"performance: performance tests of MeshPy"
6667
]

tests/conftest.py

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,51 @@ def pytest_addoption(parser: Parser) -> None:
4646
"""
4747

4848
parser.addoption(
49-
"--4C_ArborX",
49+
"--4C",
5050
action="store_true",
5151
default=False,
52-
help="Execute 4C and ArborX based tests.",
52+
help="Execute standard and 4C based tests.",
53+
)
54+
55+
parser.addoption(
56+
"--ArborX",
57+
action="store_true",
58+
default=False,
59+
help="Execute standard and ArborX based tests.",
5360
)
5461

5562
parser.addoption(
5663
"--CubitPy",
5764
action="store_true",
5865
default=False,
59-
help="Execute CubitPy based tests.",
66+
help="Execute standard and CubitPy based tests.",
67+
)
68+
69+
parser.addoption(
70+
"--Performance",
71+
action="store_true",
72+
default=False,
73+
help="Execute standard and performance tests.",
6074
)
6175

6276
parser.addoption(
63-
"--performance",
77+
"--exclude-standard-tests",
6478
action="store_true",
6579
default=False,
66-
help="Execute performance tests.",
80+
help="Exclude standard tests.",
6781
)
6882

6983

7084
def pytest_collection_modifyitems(config: Config, items: list) -> None:
7185
"""Filter tests based on their markers and provided command line options.
7286
7387
Currently configured options:
74-
`pytest`: execute tests with no markers
75-
`pytest --4C_ArborX`: execute tests with the `fourc_arborx` marker
76-
`pytest --CubitPy`: execute tests with the `cubitpy` marker
77-
`pytest --performance`: execute tests with the `performance` marker
88+
`pytest`: Execute standard tests with no markers
89+
`pytest --4C`: Execute standard tests and tests with the `fourc` marker
90+
`pytest --ArborX`: Execute standard tests and tests with the `arborx` marker
91+
`pytest --CubitPy`: Execute standard tests and tests with the `cubitpy` marker
92+
`pytest --Performance`: Execute standard tests and tests with the `performance` marker
93+
`pytest --exclude-standard-tests`: Execute tests with any other marker and exclude the standard unmarked tests
7894
7995
Args:
8096
config: Pytest config
@@ -88,16 +104,19 @@ def pytest_collection_modifyitems(config: Config, items: list) -> None:
88104
# Get all set markers for current test (e.g. `fourc_arborx`, `cubitpy`, `performance`)
89105
markers = [marker.name for marker in item.iter_markers()]
90106

91-
if config.getoption("--4C_ArborX") and "fourc_arborx" in markers:
107+
if config.getoption("--4C") and "fourc" in markers:
108+
selected_tests.append(item)
109+
110+
if config.getoption("--ArborX") and "arborx" in markers:
92111
selected_tests.append(item)
93112

94113
if config.getoption("--CubitPy") and "cubitpy" in markers:
95114
selected_tests.append(item)
96115

97-
if config.getoption("--performance") and "performance" in markers:
116+
if config.getoption("--Performance") and "performance" in markers:
98117
selected_tests.append(item)
99118

100-
if not markers:
119+
if not markers and not config.getoption("--exclude-standard-tests"):
101120
selected_tests.append(item)
102121

103122
deselected_tests = list(set(items) - set(selected_tests))
@@ -133,5 +152,5 @@ def current_test_name(request: pytest.FixtureRequest) -> str:
133152

134153

135154
@pytest.fixture
136-
def compare_result_file(reference, result, rtol, atol):
155+
def compare_results(reference, result, rtol, atol):
137156
raise NotImplementedError

tests/test_dummy.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
import pytest
3636

3737

38-
def test_dummy(reference_file_directory: Path, tmp_path: Path, current_test_name: str):
38+
def test_dummy(
39+
reference_file_directory: Path, tmp_path: Path, current_test_name: str
40+
) -> None:
3941
"""Dummy test to demonstrate pytest fixtures.
4042
4143
Args:
@@ -58,9 +60,16 @@ def test_dummy(reference_file_directory: Path, tmp_path: Path, current_test_name
5860
assert True
5961

6062

61-
@pytest.mark.fourc_arborx
62-
def test_4C_ArborX() -> None:
63-
"""Test with 4C and ArborX."""
63+
@pytest.mark.fourc
64+
def test_4C() -> None:
65+
"""Test with 4C."""
66+
67+
assert True
68+
69+
70+
@pytest.mark.arborx
71+
def test_ArborX() -> None:
72+
"""Test with ArborX."""
6473

6574
assert True
6675

0 commit comments

Comments
 (0)