def test_no_root(caplog): with mock.patch('os.geteuid') as geteuid: geteuid.return_value = 0 assert main([]) != 0 for record in caplog.records: if record.message.endswith('must not be run as root'): return assert False, "didn't find error log message about running as root"
def test_help(capsys): with pytest.raises(SystemExit): main(['--help']) out, err = capsys.readouterr() assert out.startswith('usage:') assert '--pypi-xmlrpc' in out
def test_version(capsys): with pytest.raises(SystemExit): main(['--version']) out, err = capsys.readouterr() assert out.strip() == __version__
def test_no_root(caplog): with mock.patch('os.geteuid') as geteuid: geteuid.return_value = 0 assert main([]) != 0 assert find_message(caplog.records, message='Master must not be run as root')