def test_exit_on_collection_with_maxfail_smaller_than_n_errors(
    pytester: Pytester,
) -> None:
    """
    Verify collection is aborted once maxfail errors are encountered ignoring
    further modules which would cause more collection errors.
    """
    pytester.makepyfile(**COLLECTION_ERROR_PY_FILES)

    res = pytester.runpytest("--maxfail=1")
    assert res.ret == 1
    res.stdout.fnmatch_lines(
        [
            "collected 1 item / 1 error",
            "*ERROR collecting test_02_import_error.py*",
            "*No module named *asdfa*",
            "*! stopping after 1 failures !*",
            "*= 1 error in *",
        ]
    )
    res.stdout.no_fnmatch_line("*test_03*")

    Verify collection is aborted once maxfail errors are encountered ignoring
    further modules which would cause more collection errors.
    
testing/test_collection.py