Skip to content

Commit 1b7e7df

Browse files
author
Ben Greene
committed
added tests for non-contiguous orders
1 parent 8457e58 commit 1b7e7df

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

tests/test_ordering.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,94 @@ def test_3(): pass
8989
assert item_names_for(tests_content) == ['test_3', 'test_2', 'test_1']
9090

9191

92+
def test_non_contiguous_positive(item_names_for):
93+
tests_content = """
94+
import pytest
95+
96+
@pytest.mark.run(order=10)
97+
def test_1(): pass
98+
99+
@pytest.mark.run(order=20)
100+
def test_2(): pass
101+
102+
@pytest.mark.run(order=5)
103+
def test_3(): pass
104+
"""
105+
106+
assert item_names_for(tests_content) == ['test_3', 'test_1', 'test_2']
107+
108+
109+
def test_non_contiguous_negative(item_names_for):
110+
tests_content = """
111+
import pytest
112+
113+
@pytest.mark.run(order=-10)
114+
def test_1(): pass
115+
116+
@pytest.mark.run(order=-20)
117+
def test_2(): pass
118+
119+
@pytest.mark.run(order=-5)
120+
def test_3(): pass
121+
"""
122+
123+
assert item_names_for(tests_content) == ['test_2', 'test_1', 'test_3']
124+
125+
126+
def test_non_contiguous_inc_zero(item_names_for):
127+
tests_content = """
128+
import pytest
129+
130+
@pytest.mark.run(order=10)
131+
def test_1(): pass
132+
133+
@pytest.mark.run(order=20)
134+
def test_2(): pass
135+
136+
@pytest.mark.run(order=5)
137+
def test_3(): pass
138+
139+
@pytest.mark.run(order=-10)
140+
def test_4(): pass
141+
142+
@pytest.mark.run(order=-20)
143+
def test_5(): pass
144+
145+
@pytest.mark.run(order=-5)
146+
def test_6(): pass
147+
148+
@pytest.mark.run(order=0)
149+
def test_7(): pass
150+
"""
151+
152+
assert item_names_for(tests_content) == ['test_7', 'test_3', 'test_1', 'test_2', 'test_5', 'test_4', 'test_6']
153+
154+
155+
def test_non_contiguous_inc_none(item_names_for):
156+
tests_content = """
157+
import pytest
158+
159+
@pytest.mark.run(order=5)
160+
def test_1(): pass
161+
162+
@pytest.mark.run(order=0)
163+
def test_2(): pass
164+
165+
@pytest.mark.run(order=1)
166+
def test_3(): pass
167+
168+
@pytest.mark.run(order=-1)
169+
def test_4(): pass
170+
171+
@pytest.mark.run(order=-5)
172+
def test_5(): pass
173+
174+
def test_6(): pass
175+
"""
176+
177+
assert item_names_for(tests_content) == ['test_2', 'test_3', 'test_1', 'test_6', 'test_5', 'test_4']
178+
179+
92180
def test_first_mark_class(item_names_for):
93181
tests_content = """
94182
import pytest

0 commit comments

Comments
 (0)