1
1
# -*- coding: utf-8 -*-
2
2
3
-
3
+ import re
4
4
5
5
import pytest
6
+ import pytest_ordering .author
7
+ import pytest_ordering .version
6
8
7
9
pytest_plugins = ["pytester" ]
8
10
@@ -28,7 +30,7 @@ def test_1(): pass
28
30
def test_2(): pass
29
31
"""
30
32
31
- assert ['test_1' , 'test_2' ] == item_names_for ( tests_content )
33
+ assert item_names_for ( tests_content ) == ['test_1' , 'test_2' ]
32
34
33
35
34
36
def test_first_mark (item_names_for ):
@@ -41,7 +43,7 @@ def test_1(): pass
41
43
def test_2(): pass
42
44
"""
43
45
44
- assert ['test_2' , 'test_1' ] == item_names_for ( tests_content )
46
+ assert item_names_for ( tests_content ) == ['test_2' , 'test_1' ]
45
47
46
48
47
49
def test_last_mark (item_names_for ):
@@ -54,7 +56,7 @@ def test_1(): pass
54
56
def test_2(): pass
55
57
"""
56
58
57
- assert ['test_2' , 'test_1' ] == item_names_for ( tests_content )
59
+ assert item_names_for ( tests_content ) == ['test_2' , 'test_1' ]
58
60
59
61
60
62
def test_first_last_marks (item_names_for ):
@@ -70,4 +72,127 @@ def test_2(): pass
70
72
def test_3(): pass
71
73
"""
72
74
73
- assert ['test_2' , 'test_3' , 'test_1' ] == item_names_for (tests_content )
75
+ assert item_names_for (tests_content ) == ['test_2' , 'test_3' , 'test_1' ]
76
+
77
+
78
+ def test_order_marks (item_names_for ):
79
+ tests_content = """
80
+ import pytest
81
+
82
+ @pytest.mark.run(order=-1)
83
+ def test_1(): pass
84
+
85
+ @pytest.mark.run(order=-2)
86
+ def test_2(): pass
87
+
88
+ @pytest.mark.run(order=1)
89
+ def test_3(): pass
90
+ """
91
+
92
+ assert item_names_for (tests_content ) == ['test_3' , 'test_2' , 'test_1' ]
93
+
94
+
95
+ def test_first_mark_class (item_names_for ):
96
+ tests_content = """
97
+ import pytest
98
+
99
+ def test_1(): pass
100
+
101
+
102
+ @pytest.mark.first
103
+ class TestSuite(object):
104
+
105
+ def test_3(self): pass
106
+
107
+ def test_2(self): pass
108
+
109
+ """
110
+
111
+ assert item_names_for (tests_content ) == ['test_3' , 'test_2' , 'test_1' ]
112
+
113
+
114
+ def test_last_mark_class (item_names_for ):
115
+ tests_content = """
116
+ import pytest
117
+
118
+ @pytest.mark.last
119
+ class TestSuite(object):
120
+
121
+ def test_1(self): pass
122
+
123
+ def test_2(self): pass
124
+
125
+
126
+ def test_3(): pass
127
+ """
128
+
129
+ assert item_names_for (tests_content ) == ['test_3' , 'test_1' , 'test_2' ]
130
+
131
+
132
+ def test_first_last_mark_class (item_names_for ):
133
+ tests_content = """
134
+ import pytest
135
+
136
+ @pytest.mark.last
137
+ class TestLast(object):
138
+
139
+ def test_1(self): pass
140
+
141
+ def test_2(self): pass
142
+
143
+
144
+ def test_3(): pass
145
+
146
+
147
+ @pytest.mark.first
148
+ class TestFirst(object):
149
+
150
+ def test_4(self): pass
151
+
152
+ def test_5(self): pass
153
+
154
+ """
155
+
156
+ assert item_names_for (tests_content ) == ['test_4' , 'test_5' , 'test_3' , 'test_1' , 'test_2' ]
157
+
158
+
159
+ def test_order_mark_class (item_names_for ):
160
+ tests_content = """
161
+ import pytest
162
+
163
+ @pytest.mark.run(order=-1)
164
+ class TestLast(object):
165
+
166
+ def test_1(self): pass
167
+
168
+ def test_2(self): pass
169
+
170
+
171
+ @pytest.mark.run(order=0)
172
+ def test_3(): pass
173
+
174
+
175
+ @pytest.mark.run(order=-2)
176
+ class TestFirst(object):
177
+
178
+ def test_4(self): pass
179
+
180
+ def test_5(self): pass
181
+ """
182
+
183
+ assert item_names_for (tests_content ) == ['test_3' , 'test_4' , 'test_5' , 'test_1' , 'test_2' ]
184
+
185
+
186
+ def test_run_marker_registered (capsys ):
187
+ pytest .main ('--markers' )
188
+ out , err = capsys .readouterr ()
189
+ assert '@pytest.mark.run' in out
190
+
191
+
192
+ def test_version_valid ():
193
+ assert re .match (r'[0-9]+\.[0-9]+(\.[0-9]+)?$' ,
194
+ pytest_ordering .version .__version__ )
195
+
196
+
197
+ def test_author_present ():
198
+ assert hasattr (pytest_ordering .author , '__author__' )
0 commit comments