File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -335,6 +335,54 @@ def pytest_sessionfinish():
335
335
assert res .ret == ExitCode .NO_TESTS_COLLECTED
336
336
337
337
338
+ def test_collection_args_do_not_duplicate_modules (pytester : Pytester ) -> None :
339
+ """Test that when multiple collection args are specified on the command line
340
+ for the same module, only a single Module collector is created.
341
+
342
+ Regression test for #723, #3358.
343
+ """
344
+ pytester .makepyfile (
345
+ ** {
346
+ "d/test_it" : """
347
+ def test_1(): pass
348
+ def test_2(): pass
349
+ """
350
+ }
351
+ )
352
+
353
+ result = pytester .runpytest (
354
+ "--collect-only" ,
355
+ "d/test_it.py::test_1" ,
356
+ "d/test_it.py::test_2" ,
357
+ )
358
+ result .stdout .fnmatch_lines (
359
+ [
360
+ "<Module d/test_it.py>" ,
361
+ " <Function test_1>" ,
362
+ " <Function test_2>" ,
363
+ ],
364
+ consecutive = True ,
365
+ )
366
+
367
+ # Different, but related case.
368
+ result = pytester .runpytest (
369
+ "--collect-only" ,
370
+ "--keep-duplicates" ,
371
+ "d" ,
372
+ "d" ,
373
+ )
374
+ result .stdout .fnmatch_lines (
375
+ [
376
+ "<Module d/test_it.py>" ,
377
+ " <Function test_1>" ,
378
+ " <Function test_2>" ,
379
+ " <Function test_1>" ,
380
+ " <Function test_2>" ,
381
+ ],
382
+ consecutive = True ,
383
+ )
384
+
385
+
338
386
@pytest .mark .parametrize ("path" , ["root" , "{relative}/root" , "{environment}/root" ])
339
387
def test_rootdir_option_arg (
340
388
pytester : Pytester , monkeypatch : MonkeyPatch , path : str
You can’t perform that action at this time.
0 commit comments