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):
208208 initstate = 2
209209 session .exitstatus = doit (config , session ) or 0
210210 except UsageError :
211+ session .exitstatus = EXIT_USAGEERROR
211212 raise
212213 except Failed :
213214 session .exitstatus = EXIT_TESTSFAILED
Original file line number Diff line number Diff line change @@ -428,9 +428,20 @@ def test_a():
428428 assert result .ret == 4 # usage error only if item not found
429429
430430 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+ )
431440 testdir .makepyfile (test_a = "def" , test_b = "def" )
432441 result = testdir .runpytest ("test_a.py::a" , "test_b.py::b" )
433442 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
434445
435446 @pytest .mark .usefixtures ("recwarn" )
436447 def test_namespace_import_doesnt_confuse_import_hook (self , testdir ):
You can’t perform that action at this time.
0 commit comments