Skip to content

Commit 0e92964

Browse files
committed
Fix handling of more than one marker attribute
- increase code coverage
1 parent 9be484f commit 0e92964

File tree

4 files changed

+61
-3
lines changed

4 files changed

+61
-3
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Unreleased
44

5+
## [Version 0.9.3](https://pypi.org/project/pytest-order/0.9.3/) (2021-01-14)
6+
Bugfix release.
7+
8+
### Fixes
9+
- fixed handling of more than one attribute in an order marker
10+
511
## [Version 0.9.2](https://pypi.org/project/pytest-order/0.9.2/) (2020-11-13)
612
Friday the 13th release.
713

pytest_order/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ def mark_binning(item, keys, start, end, before, after, dep, unordered, alias):
166166
end.setdefault(order, []).append(item)
167167
else:
168168
start.setdefault(order, []).append(item)
169-
elif before_mark:
169+
if before_mark:
170170
before.setdefault(full_name(item, before_mark), []).append(item)
171-
elif after_mark:
171+
if after_mark:
172172
after.setdefault(
173173
full_name(item, after_mark), []).append(item)
174174
handled = True

tests/test_dependency.py

+16
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,19 @@ def test_c(self):
276276
warning = ("cannot execute test relative to others: "
277277
"test_3 enqueue them behind the others")
278278
assert warning in out
279+
280+
281+
def test_unsupported_order_with_dependency(item_names_for):
282+
test_content = """
283+
import pytest
284+
285+
@pytest.mark.dependency(depends=["test_2"])
286+
@pytest.mark.order("unknown")
287+
def test_1():
288+
pass
289+
290+
def test_2():
291+
pass
292+
"""
293+
with pytest.warns(UserWarning, match="Unknown order attribute:'unknown'"):
294+
assert item_names_for(test_content) == ["test_2", "test_1"]

tests/test_relative_ordering.py

+37-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def test_3():
267267
assert item_names_for(test_content) == ["test_3", "test_2", "test_1"]
268268

269269

270-
def test_combined_markers(item_names_for):
270+
def test_combined_markers1(item_names_for):
271271
test_content = """
272272
import pytest
273273
@@ -285,6 +285,42 @@ def test_3():
285285
assert item_names_for(test_content) == ["test_3", "test_1", "test_2"]
286286

287287

288+
def test_combined_markers2(item_names_for):
289+
test_content = """
290+
import pytest
291+
292+
def test_1():
293+
pass
294+
295+
@pytest.mark.order(index=2, before="test_1")
296+
def test_2():
297+
pass
298+
299+
@pytest.mark.order(index=1, before="test_1")
300+
def test_3():
301+
pass
302+
"""
303+
assert item_names_for(test_content) == ["test_3", "test_2", "test_1"]
304+
305+
306+
def test_combined_markers3(item_names_for):
307+
test_content = """
308+
import pytest
309+
310+
def test_1():
311+
pass
312+
313+
@pytest.mark.order(index=2, before="test_3")
314+
def test_2():
315+
pass
316+
317+
@pytest.mark.order(index=1, before="test_1")
318+
def test_3():
319+
pass
320+
"""
321+
assert item_names_for(test_content) == ["test_2", "test_3", "test_1"]
322+
323+
288324
def test_dependency_after_unknown_test(item_names_for, capsys):
289325
test_content = """
290326
import pytest

0 commit comments

Comments
 (0)