Ejemplo n.º 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"
Ejemplo n.º 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
Ejemplo n.º 3
0
def test_version(capsys):
    with pytest.raises(SystemExit):
        main(['--version'])
    out, err = capsys.readouterr()
    assert out.strip() == __version__
Ejemplo n.º 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')