File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -208,6 +208,7 @@ def wrap_session(config, doit):
208
208
initstate = 2
209
209
session .exitstatus = doit (config , session ) or 0
210
210
except UsageError :
211
+ session .exitstatus = EXIT_USAGEERROR
211
212
raise
212
213
except Failed :
213
214
session .exitstatus = EXIT_TESTSFAILED
Original file line number Diff line number Diff line change @@ -428,9 +428,20 @@ def test_a():
428
428
assert result .ret == 4 # usage error only if item not found
429
429
430
430
def test_report_all_failed_collections_initargs (self , testdir ):
431
+ testdir .makeconftest (
432
+ """
433
+ from _pytest.main import EXIT_USAGEERROR
434
+
435
+ def pytest_sessionfinish(exitstatus):
436
+ assert exitstatus == EXIT_USAGEERROR
437
+ print("pytest_sessionfinish_called")
438
+ """
439
+ )
431
440
testdir .makepyfile (test_a = "def" , test_b = "def" )
432
441
result = testdir .runpytest ("test_a.py::a" , "test_b.py::b" )
433
442
result .stderr .fnmatch_lines (["*ERROR*test_a.py::a*" , "*ERROR*test_b.py::b*" ])
443
+ result .stdout .fnmatch_lines (["pytest_sessionfinish_called" ])
444
+ assert result .ret == EXIT_USAGEERROR
434
445
435
446
@pytest .mark .usefixtures ("recwarn" )
436
447
def test_namespace_import_doesnt_confuse_import_hook (self , testdir ):
You can’t perform that action at this time.
0 commit comments