def METHOD_NAME(command, expected, capsys, monkeypatch):
    # Ensure that sys.argv of the test command does not affect the test environment.
    monkeypatch.setattr('sys.argv', command or [])
    with pytest.raises(SystemExit) as exc:
        main(command)
    stdout, stderr = capsys.readouterr()
    assert exc.value.code == 2, 'Should raise SystemExit with return code 2'
    assert expected['out'] in stdout
    assert expected['err'] in stderr