Пример #1
0
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"
Пример #2
0
def test_help(capsys):
    with pytest.raises(SystemExit):
        main(['--help'])
    out, err = capsys.readouterr()
    assert out.startswith('usage:')
    assert '--pypi-xmlrpc' in out
Пример #3
0
def test_version(capsys):
    with pytest.raises(SystemExit):
        main(['--version'])
    out, err = capsys.readouterr()
    assert out.strip() == __version__
Пример #4
0
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')