def test_misconfiguration_handling(capsys: Any, config_file_contents: list[str], message_part: str) -> None:
    """Invalid configuration raises `SystemExit` with a precise error message."""
    contents = "\n".join(config_file_contents).expandtabs(4)
    with write_to_file(contents) as filename:
        with pytest.raises(SystemExit, match="2"):
            DjangoPluginConfig(filename)

    error_message = "usage: " + TEMPLATE.format(message_part)
    assert error_message == capsys.readouterr().err
Invalid configuration raises `SystemExit` with a precise error message.
tests/test_error_handling.py