@@ -226,6 +226,114 @@ def test_foo(foo):
226
226
result = testdir .runpytest ()
227
227
assert result .ret == 0
228
228
229
+ def test_override_parametrized_fixture_conftest_module (self , testdir ):
230
+ """Test override of the parametrized fixture with non-parametrized one on the test module level."""
231
+ testdir .makeconftest ("""
232
+ import pytest
233
+
234
+ @pytest.fixture(params=[1, 2, 3])
235
+ def spam(request):
236
+ return request.param
237
+ """ )
238
+ testfile = testdir .makepyfile ("""
239
+ import pytest
240
+
241
+ @pytest.fixture
242
+ def spam():
243
+ return 'spam'
244
+
245
+ def test_spam(spam):
246
+ assert spam == 'spam'
247
+ """ )
248
+ result = testdir .runpytest ()
249
+ result .stdout .fnmatch_lines (["*1 passed*" ])
250
+ result = testdir .runpytest (testfile )
251
+ result .stdout .fnmatch_lines (["*1 passed*" ])
252
+
253
+ def test_override_parametrized_fixture_conftest_conftest (self , testdir ):
254
+ """Test override of the parametrized fixture with non-parametrized one on the conftest level."""
255
+ testdir .makeconftest ("""
256
+ import pytest
257
+
258
+ @pytest.fixture(params=[1, 2, 3])
259
+ def spam(request):
260
+ return request.param
261
+ """ )
262
+ subdir = testdir .mkpydir ('subdir' )
263
+ subdir .join ("conftest.py" ).write (py .code .Source ("""
264
+ import pytest
265
+
266
+ @pytest.fixture
267
+ def spam():
268
+ return 'spam'
269
+ """ ))
270
+ testfile = subdir .join ("test_spam.py" )
271
+ testfile .write (py .code .Source ("""
272
+ def test_spam(spam):
273
+ assert spam == "spam"
274
+ """ ))
275
+ result = testdir .runpytest ()
276
+ result .stdout .fnmatch_lines (["*1 passed*" ])
277
+ result = testdir .runpytest (testfile )
278
+ result .stdout .fnmatch_lines (["*1 passed*" ])
279
+
280
+ def test_override_non_parametrized_fixture_conftest_module (self , testdir ):
281
+ """Test override of the non-parametrized fixture with parametrized one on the test module level."""
282
+ testdir .makeconftest ("""
283
+ import pytest
284
+
285
+ @pytest.fixture
286
+ def spam():
287
+ return 'spam'
288
+ """ )
289
+ testfile = testdir .makepyfile ("""
290
+ import pytest
291
+
292
+ @pytest.fixture(params=[1, 2, 3])
293
+ def spam(request):
294
+ return request.param
295
+
296
+ params = {'spam': 1}
297
+
298
+ def test_spam(spam):
299
+ assert spam == params['spam']
300
+ params['spam'] += 1
301
+ """ )
302
+ result = testdir .runpytest ()
303
+ result .stdout .fnmatch_lines (["*3 passed*" ])
304
+ result = testdir .runpytest (testfile )
305
+ result .stdout .fnmatch_lines (["*3 passed*" ])
306
+
307
+ def test_override_non_parametrized_fixture_conftest_conftest (self , testdir ):
308
+ """Test override of the non-parametrized fixture with parametrized one on the conftest level."""
309
+ testdir .makeconftest ("""
310
+ import pytest
311
+
312
+ @pytest.fixture
313
+ def spam():
314
+ return 'spam'
315
+ """ )
316
+ subdir = testdir .mkpydir ('subdir' )
317
+ subdir .join ("conftest.py" ).write (py .code .Source ("""
318
+ import pytest
319
+
320
+ @pytest.fixture(params=[1, 2, 3])
321
+ def spam(request):
322
+ return request.param
323
+ """ ))
324
+ testfile = subdir .join ("test_spam.py" )
325
+ testfile .write (py .code .Source ("""
326
+ params = {'spam': 1}
327
+
328
+ def test_spam(spam):
329
+ assert spam == params['spam']
330
+ params['spam'] += 1
331
+ """ ))
332
+ result = testdir .runpytest ()
333
+ result .stdout .fnmatch_lines (["*3 passed*" ])
334
+ result = testdir .runpytest (testfile )
335
+ result .stdout .fnmatch_lines (["*3 passed*" ])
336
+
229
337
def test_autouse_fixture_plugin (self , testdir ):
230
338
# A fixture from a plugin has no baseid set, which screwed up
231
339
# the autouse fixture handling.
0 commit comments