Skip to content

Commit 5104e18

Browse files
committed
Avoid unknown marker warnings in tests
1 parent 5861b29 commit 5104e18

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# pytest-order Release Notes
22

3+
## Infrastructure
4+
- avoid unknown marker warning in tests (see [#101](https://github.com/pytest-dev/pytest-order/issues/101))
5+
36
## [Version 1.2.0](https://pypi.org/project/pytest-order/1.2.0/) (2023-11-18)
47
Allows using custom markers for ordering.
58

69
### New features
7-
* added option `--order-marker-prefix` to allow using custom markers for ordering
10+
- added option `--order-marker-prefix` to allow using custom markers for ordering
811

912
### Infrastructure
1013
- added pre-commit hook for linters

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Features
4949
- sparse ordering of tests via the
5050
[sparse-ordering](https://pytest-order.readthedocs.io/en/stable/configuration.html#sparse-ordering) option
5151
- usage of custom markers for ordering using the
52-
[sparse-ordering](https://pytest-order.readthedocs.io/en/stable/configuration.html#order-marker-prefix) option
52+
[order-marker-prefix](https://pytest-order.readthedocs.io/en/stable/configuration.html#order-marker-prefix) option
5353

5454
Overview
5555
--------

tests/test_marker_prefix.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,35 @@ def test_c():
2222
)
2323

2424

25+
@pytest.fixture(scope="module")
26+
def conftest_file():
27+
yield (
28+
"""
29+
def pytest_configure(config):
30+
config.addinivalue_line("markers", "my1: used in marker prefix test")
31+
config.addinivalue_line("markers", "my2: used in marker prefix test")
32+
config.addinivalue_line("markers", "my3: used in marker prefix test")
33+
"""
34+
)
35+
36+
2537
@pytest.fixture
26-
def marker_test(test_path, marker_test_file):
38+
def marker_test(test_path, marker_test_file, conftest_file):
39+
test_path.makepyfile(conftest=conftest_file)
2740
test_path.makepyfile(test_marker=marker_test_file)
2841
yield test_path
2942

3043

31-
def test_no_ordering(marker_test_file, item_names_for):
32-
assert item_names_for(marker_test_file) == ["test_a", "test_b", "test_c"]
44+
def test_no_ordering(marker_test):
45+
result = marker_test.runpytest("-v")
46+
result.assert_outcomes(passed=3, skipped=0)
47+
result.stdout.fnmatch_lines(
48+
[
49+
"test_marker.py::test_a PASSED",
50+
"test_marker.py::test_b PASSED",
51+
"test_marker.py::test_c PASSED",
52+
]
53+
)
3354

3455

3556
def test_order_with_marker_prefix(marker_test):
@@ -110,7 +131,8 @@ def test_c():
110131
)
111132

112133

113-
def test_mix_marker_prefix_with_order_marks(test_path):
134+
def test_mix_marker_prefix_with_order_marks(test_path, conftest_file):
135+
test_path.makepyfile(conftest=conftest_file)
114136
test_path.makepyfile(
115137
test_marker=(
116138
"""

0 commit comments

Comments
 (0)