|
2 | 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this |
3 | 3 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
4 | 4 |
|
| 5 | +import pytest |
| 6 | + |
5 | 7 | pytest_plugins = "pytester", |
6 | 8 |
|
7 | 9 |
|
@@ -111,3 +113,139 @@ def test_this(self): |
111 | 113 | '*test_unittest_test.py::ClassStyleTest::test_this PASSED*', |
112 | 114 | '*1 passed*', |
113 | 115 | ]) |
| 116 | + |
| 117 | + @pytest.mark.parametrize(['scope', 'lines'], [ |
| 118 | + ('session', [ |
| 119 | + '*test_1.py::test_repeat1[[]1/2[]] PASSED*', |
| 120 | + '*test_1.py::test_repeat2[[]1/2[]] PASSED*', |
| 121 | + '*test_2.py::test_repeat3[[]1/2[]] PASSED*', |
| 122 | + '*test_2.py::test_repeat4[[]1/2[]] PASSED*', |
| 123 | + '*test_3.py::TestRepeat1::test_repeat5[[]1/2[]] PASSED*', |
| 124 | + '*test_3.py::TestRepeat1::test_repeat6[[]1/2[]] PASSED*', |
| 125 | + '*test_3.py::TestRepeat2::test_repeat7[[]1/2[]] PASSED*', |
| 126 | + '*test_3.py::TestRepeat2::test_repeat8[[]1/2[]] PASSED*', |
| 127 | + '*test_1.py::test_repeat1[[]2/2[]] PASSED*', |
| 128 | + '*test_1.py::test_repeat2[[]2/2[]] PASSED*', |
| 129 | + '*test_2.py::test_repeat3[[]2/2[]] PASSED*', |
| 130 | + '*test_2.py::test_repeat4[[]2/2[]] PASSED*', |
| 131 | + '*test_3.py::TestRepeat1::test_repeat5[[]2/2[]] PASSED*', |
| 132 | + '*test_3.py::TestRepeat1::test_repeat6[[]2/2[]] PASSED*', |
| 133 | + '*test_3.py::TestRepeat2::test_repeat7[[]2/2[]] PASSED*', |
| 134 | + '*test_3.py::TestRepeat2::test_repeat8[[]2/2[]] PASSED*', |
| 135 | + '*16 passed*', |
| 136 | + ]), |
| 137 | + ('module', [ |
| 138 | + '*test_1.py::test_repeat1[[]1/2[]] PASSED*', |
| 139 | + '*test_1.py::test_repeat2[[]1/2[]] PASSED*', |
| 140 | + '*test_1.py::test_repeat1[[]2/2[]] PASSED*', |
| 141 | + '*test_1.py::test_repeat2[[]2/2[]] PASSED*', |
| 142 | + '*test_2.py::test_repeat3[[]1/2[]] PASSED*', |
| 143 | + '*test_2.py::test_repeat4[[]1/2[]] PASSED*', |
| 144 | + '*test_2.py::test_repeat3[[]2/2[]] PASSED*', |
| 145 | + '*test_2.py::test_repeat4[[]2/2[]] PASSED*', |
| 146 | + '*test_3.py::TestRepeat1::test_repeat5[[]1/2[]] PASSED*', |
| 147 | + '*test_3.py::TestRepeat1::test_repeat6[[]1/2[]] PASSED*', |
| 148 | + '*test_3.py::TestRepeat2::test_repeat7[[]1/2[]] PASSED*', |
| 149 | + '*test_3.py::TestRepeat2::test_repeat8[[]1/2[]] PASSED*', |
| 150 | + '*test_3.py::TestRepeat1::test_repeat5[[]2/2[]] PASSED*', |
| 151 | + '*test_3.py::TestRepeat1::test_repeat6[[]2/2[]] PASSED*', |
| 152 | + '*test_3.py::TestRepeat2::test_repeat7[[]2/2[]] PASSED*', |
| 153 | + '*test_3.py::TestRepeat2::test_repeat8[[]2/2[]] PASSED*', |
| 154 | + '*16 passed*', |
| 155 | + ]), |
| 156 | + ('class', [ |
| 157 | + '*test_1.py::test_repeat1[[]1/2[]] PASSED*', |
| 158 | + '*test_1.py::test_repeat2[[]1/2[]] PASSED*', |
| 159 | + '*test_1.py::test_repeat1[[]2/2[]] PASSED*', |
| 160 | + '*test_1.py::test_repeat2[[]2/2[]] PASSED*', |
| 161 | + '*test_2.py::test_repeat3[[]1/2[]] PASSED*', |
| 162 | + '*test_2.py::test_repeat4[[]1/2[]] PASSED*', |
| 163 | + '*test_2.py::test_repeat3[[]2/2[]] PASSED*', |
| 164 | + '*test_2.py::test_repeat4[[]2/2[]] PASSED*', |
| 165 | + '*test_3.py::TestRepeat1::test_repeat5[[]1/2[]] PASSED*', |
| 166 | + '*test_3.py::TestRepeat1::test_repeat6[[]1/2[]] PASSED*', |
| 167 | + '*test_3.py::TestRepeat1::test_repeat5[[]2/2[]] PASSED*', |
| 168 | + '*test_3.py::TestRepeat1::test_repeat6[[]2/2[]] PASSED*', |
| 169 | + '*test_3.py::TestRepeat2::test_repeat7[[]1/2[]] PASSED*', |
| 170 | + '*test_3.py::TestRepeat2::test_repeat8[[]1/2[]] PASSED*', |
| 171 | + '*test_3.py::TestRepeat2::test_repeat7[[]2/2[]] PASSED*', |
| 172 | + '*test_3.py::TestRepeat2::test_repeat8[[]2/2[]] PASSED*', |
| 173 | + '*16 passed*', |
| 174 | + ]), |
| 175 | + ('function', [ |
| 176 | + '*test_1.py::test_repeat1[[]1/2[]] PASSED*', |
| 177 | + '*test_1.py::test_repeat1[[]2/2[]] PASSED*', |
| 178 | + '*test_1.py::test_repeat2[[]1/2[]] PASSED*', |
| 179 | + '*test_1.py::test_repeat2[[]2/2[]] PASSED*', |
| 180 | + '*test_2.py::test_repeat3[[]1/2[]] PASSED*', |
| 181 | + '*test_2.py::test_repeat3[[]2/2[]] PASSED*', |
| 182 | + '*test_2.py::test_repeat4[[]1/2[]] PASSED*', |
| 183 | + '*test_2.py::test_repeat4[[]2/2[]] PASSED*', |
| 184 | + '*test_3.py::TestRepeat1::test_repeat5[[]1/2[]] PASSED*', |
| 185 | + '*test_3.py::TestRepeat1::test_repeat5[[]2/2[]] PASSED*', |
| 186 | + '*test_3.py::TestRepeat1::test_repeat6[[]1/2[]] PASSED*', |
| 187 | + '*test_3.py::TestRepeat1::test_repeat6[[]2/2[]] PASSED*', |
| 188 | + '*test_3.py::TestRepeat2::test_repeat7[[]1/2[]] PASSED*', |
| 189 | + '*test_3.py::TestRepeat2::test_repeat7[[]2/2[]] PASSED*', |
| 190 | + '*test_3.py::TestRepeat2::test_repeat8[[]1/2[]] PASSED*', |
| 191 | + '*test_3.py::TestRepeat2::test_repeat8[[]2/2[]] PASSED*', |
| 192 | + '*16 passed*', |
| 193 | + ]), |
| 194 | + ]) |
| 195 | + def test_scope(self, testdir, scope, lines): |
| 196 | + testdir.makepyfile(test_1=""" |
| 197 | + def test_repeat1(): |
| 198 | + pass |
| 199 | +
|
| 200 | + def test_repeat2(): |
| 201 | + pass |
| 202 | + """) |
| 203 | + testdir.makepyfile(test_2=""" |
| 204 | + def test_repeat3(): |
| 205 | + pass |
| 206 | +
|
| 207 | + def test_repeat4(): |
| 208 | + pass |
| 209 | + """) |
| 210 | + testdir.makepyfile(test_3=""" |
| 211 | + class TestRepeat1(object): |
| 212 | + def test_repeat5(self): |
| 213 | + pass |
| 214 | + def test_repeat6(self): |
| 215 | + pass |
| 216 | + class TestRepeat2(object): |
| 217 | + def test_repeat7(self): |
| 218 | + pass |
| 219 | + def test_repeat8(self): |
| 220 | + pass |
| 221 | + """) |
| 222 | + result = testdir.runpytest('-v', '--count', '2', '--repeat-scope', |
| 223 | + scope) |
| 224 | + result.stdout.fnmatch_lines(lines) |
| 225 | + assert result.ret == 0 |
| 226 | + |
| 227 | + def test_omitted_scope(self, testdir): |
| 228 | + testdir.makepyfile(""" |
| 229 | + def test_repeat1(): |
| 230 | + pass |
| 231 | +
|
| 232 | + def test_repeat2(): |
| 233 | + pass |
| 234 | + """) |
| 235 | + result = testdir.runpytest('-v', '--count', '2') |
| 236 | + result.stdout.fnmatch_lines([ |
| 237 | + '*test_omitted_scope.py::test_repeat1[[]1/2[]] PASSED*', |
| 238 | + '*test_omitted_scope.py::test_repeat1[[]2/2[]] PASSED*', |
| 239 | + '*test_omitted_scope.py::test_repeat2[[]1/2[]] PASSED*', |
| 240 | + '*test_omitted_scope.py::test_repeat2[[]2/2[]] PASSED*', |
| 241 | + '*4 passed*', |
| 242 | + ]) |
| 243 | + assert result.ret == 0 |
| 244 | + |
| 245 | + def test_invalid_scope(self, testdir): |
| 246 | + testdir.makepyfile(""" |
| 247 | + def test_repeat(): |
| 248 | + pass |
| 249 | + """) |
| 250 | + result = testdir.runpytest('--count', '2', '--repeat-scope', 'a') |
| 251 | + assert result.ret == 2 |
0 commit comments