-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathtest_order_group_scope_dep.py
178 lines (157 loc) · 5.29 KB
/
test_order_group_scope_dep.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
import pytest
@pytest.fixture
def fixture_path(test_path):
test_path.makepyfile(
test_dep1=(
"""
import pytest
class Test1:
@pytest.mark.dependency(depends=['Test2::test_two'])
def test_one(self):
assert True
@pytest.mark.dependency(depends=['test_three'], scope="class")
def test_two(self):
assert True
@pytest.mark.dependency
def test_three(self):
assert True
class Test2:
def test_one(self):
assert True
@pytest.mark.dependency(
depends=['test_dep3.py::test_two'], scope='session'
)
def test_two(self):
assert True
"""
),
test_dep2=(
"""
import pytest
@pytest.mark.dependency(
depends=['test_dep3.py::test_two'], scope='session'
)
def test_one():
assert True
def test_two():
assert True
"""
),
test_dep3=(
"""
import pytest
def test_one():
assert True
@pytest.mark.dependency
def test_two():
assert True
"""
),
test_dep4=(
"""
import pytest
def test_one():
assert True
def test_two():
assert True
"""
),
)
yield test_path
@pytest.mark.skipif(
pytest.__version__.startswith("3.7."),
reason="pytest-dependency < 0.5 does not support session scope",
)
def test_session_scope(fixture_path):
result = fixture_path.runpytest("-v", "--order-dependencies")
result.assert_outcomes(passed=11, failed=0)
result.stdout.fnmatch_lines(
[
"test_dep1.py::Test1::test_three PASSED",
"test_dep1.py::Test1::test_two PASSED",
"test_dep1.py::Test2::test_one PASSED",
"test_dep2.py::test_two PASSED",
"test_dep3.py::test_one PASSED",
"test_dep3.py::test_two PASSED",
"test_dep1.py::Test2::test_two PASSED",
"test_dep1.py::Test1::test_one PASSED",
"test_dep2.py::test_one PASSED",
"test_dep4.py::test_one PASSED",
"test_dep4.py::test_two PASSED",
]
)
@pytest.mark.skipif(
pytest.__version__.startswith("3.7."),
reason="pytest-dependency < 0.5 does not support session scope",
)
def test_module_group_scope(fixture_path):
result = fixture_path.runpytest(
"-v", "--order-dependencies", "--order-group-scope=module"
)
result.assert_outcomes(passed=11, failed=0)
result.stdout.fnmatch_lines(
[
"test_dep3.py::test_one PASSED",
"test_dep3.py::test_two PASSED",
"test_dep1.py::Test1::test_three PASSED",
"test_dep1.py::Test1::test_two PASSED",
"test_dep1.py::Test2::test_one PASSED",
"test_dep1.py::Test2::test_two PASSED",
"test_dep1.py::Test1::test_one PASSED",
"test_dep2.py::test_one PASSED",
"test_dep2.py::test_two PASSED",
"test_dep4.py::test_one PASSED",
"test_dep4.py::test_two PASSED",
]
)
@pytest.mark.skipif(
pytest.__version__.startswith("3.7."),
reason="pytest-dependency < 0.5 does not support session scope",
)
def test_class_group_scope(fixture_path):
result = fixture_path.runpytest(
"-v", "--order-dependencies", "--order-group-scope=class"
)
result.assert_outcomes(passed=11, failed=0)
result.stdout.fnmatch_lines(
[
"test_dep3.py::test_one PASSED",
"test_dep3.py::test_two PASSED",
"test_dep1.py::Test2::test_one PASSED",
"test_dep1.py::Test2::test_two PASSED",
"test_dep1.py::Test1::test_one PASSED",
"test_dep1.py::Test1::test_three PASSED",
"test_dep1.py::Test1::test_two PASSED",
"test_dep2.py::test_one PASSED",
"test_dep2.py::test_two PASSED",
"test_dep4.py::test_one PASSED",
"test_dep4.py::test_two PASSED",
]
)
@pytest.mark.skipif(
pytest.__version__.startswith("3.7."),
reason="pytest-dependency < 0.5 does not support session scope",
)
def test_class_group_scope_module_scope(fixture_path):
result = fixture_path.runpytest(
"-v",
"--order-dependencies",
"--order-group-scope=class",
"--order-scope=module",
)
result.assert_outcomes(passed=8, skipped=3)
result.stdout.fnmatch_lines(
[
"test_dep1.py::Test2::test_one PASSED",
"test_dep1.py::Test2::test_two SKIPPED*",
"test_dep1.py::Test1::test_one SKIPPED*",
"test_dep1.py::Test1::test_three PASSED",
"test_dep1.py::Test1::test_two PASSED",
"test_dep2.py::test_one SKIPPED*",
"test_dep2.py::test_two PASSED",
"test_dep3.py::test_one PASSED",
"test_dep3.py::test_two PASSED",
"test_dep4.py::test_one PASSED",
"test_dep4.py::test_two PASSED",
]
)