Skip to content

Commit

Permalink
Avoid unknown marker warnings in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbean-bremen committed Feb 12, 2024
1 parent 5861b29 commit 5104e18
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# pytest-order Release Notes

## Infrastructure
- avoid unknown marker warning in tests (see [#101](https://github.com/pytest-dev/pytest-order/issues/101))

## [Version 1.2.0](https://pypi.org/project/pytest-order/1.2.0/) (2023-11-18)
Allows using custom markers for ordering.

### New features
* added option `--order-marker-prefix` to allow using custom markers for ordering
- added option `--order-marker-prefix` to allow using custom markers for ordering

### Infrastructure
- added pre-commit hook for linters
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Features
- sparse ordering of tests via the
[sparse-ordering](https://pytest-order.readthedocs.io/en/stable/configuration.html#sparse-ordering) option
- usage of custom markers for ordering using the
[sparse-ordering](https://pytest-order.readthedocs.io/en/stable/configuration.html#order-marker-prefix) option
[order-marker-prefix](https://pytest-order.readthedocs.io/en/stable/configuration.html#order-marker-prefix) option

Overview
--------
Expand Down
30 changes: 26 additions & 4 deletions tests/test_marker_prefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,35 @@ def test_c():
)


@pytest.fixture(scope="module")
def conftest_file():
yield (
"""
def pytest_configure(config):
config.addinivalue_line("markers", "my1: used in marker prefix test")
config.addinivalue_line("markers", "my2: used in marker prefix test")
config.addinivalue_line("markers", "my3: used in marker prefix test")
"""
)


@pytest.fixture
def marker_test(test_path, marker_test_file):
def marker_test(test_path, marker_test_file, conftest_file):
test_path.makepyfile(conftest=conftest_file)
test_path.makepyfile(test_marker=marker_test_file)
yield test_path


def test_no_ordering(marker_test_file, item_names_for):
assert item_names_for(marker_test_file) == ["test_a", "test_b", "test_c"]
def test_no_ordering(marker_test):
result = marker_test.runpytest("-v")
result.assert_outcomes(passed=3, skipped=0)
result.stdout.fnmatch_lines(
[
"test_marker.py::test_a PASSED",
"test_marker.py::test_b PASSED",
"test_marker.py::test_c PASSED",
]
)


def test_order_with_marker_prefix(marker_test):
Expand Down Expand Up @@ -110,7 +131,8 @@ def test_c():
)


def test_mix_marker_prefix_with_order_marks(test_path):
def test_mix_marker_prefix_with_order_marks(test_path, conftest_file):
test_path.makepyfile(conftest=conftest_file)
test_path.makepyfile(
test_marker=(
"""
Expand Down

0 comments on commit 5104e18

Please sign in to comment.