def test_exit_on_collection_with_maxfail_smaller_than_n_errors(testdir):
 testdir.makepyfile(**COLLECTION_ERROR_PY_FILES)
 res = testdir.runpytest('--maxfail=1')
 assert (res.ret == 2)
 res.stdout.fnmatch_lines(['*ERROR collecting test_02_import_error.py*', '*No module named *asdfa*', '*Interrupted: stopping after 1 failures*'])
 assert ('test_03' not in res.stdout.str())

def test_exit_on_collection_with_maxfail_smaller_than_n_errors ( testdir ) : testdir . makepyfile ( ** COLLECTION_ERROR_PY_FILES ) res = testdir . runpytest ( '--maxfail=1' ) assert ( res . ret == 2 ) res . stdout . fnmatch_lines ( [ '*ERROR collecting test_02_import_error.py*' , '*No module named *asdfa*' , '*Interrupted: stopping after 1 failures*' ] ) assert ( 'test_03' not in res . stdout . str ( ) )
verify collection is aborted once maxfail errors are encountered ignoring further modules which would cause more collection errors .