Exemplo n.º 1
0
def test_terse_excepthook(capsys, app):
    app.verbose = False
    try:
        raise FakeError('example')
    except:
        with pytest.raises(SystemExit) as excinfo:
            app.excepthook(*sys.exc_info())
    out, err = capsys.readouterr()
    assert not out
    assert err == '(pass -v for the full traceback)\nFakeError: example\n'
    assert excinfo_arg_0(excinfo) == 1
Exemplo n.º 2
0
def test_terse_excepthook(capsys, app):
    app.verbose = False
    try:
        raise FakeError('example')
    except:
        with pytest.raises(SystemExit) as excinfo:
            app.excepthook(*sys.exc_info())
    out, err = capsys.readouterr()
    assert not out
    assert err == '(pass -v for the full traceback)\nFakeError: example\n'
    assert excinfo_arg_0(excinfo) == 1
Exemplo n.º 3
0
def test_verbose_errormark(capsys, app):
    app.verbose = True
    exc = FakeError('example')
    exc._errormark = 'testing this code {0} {spam}', 8, ('foo', 'bar'), {'spam': 'eggs'}
    try:
        raise exc
    except:
        exc_info = sys.exc_info()
    with pytest.raises(SystemExit) as excinfo:
        app.excepthook(*exc_info)
    tb_string = ''.join(traceback.format_exception(*exc_info))
    out, err = capsys.readouterr()
    assert not out
    assert err == 'an error occurred testing this code foo eggs\n' + tb_string
    assert excinfo_arg_0(excinfo) == 8
Exemplo n.º 4
0
def test_terse_errormark(capsys, app):
    app.verbose = False
    exc = FakeError('example')
    exc._errormark = 'testing this code {0} {spam}', 8, ('foo', 'bar'), {'spam': 'eggs'}
    try:
        raise exc
    except:
        with pytest.raises(SystemExit) as excinfo:
            app.excepthook(*sys.exc_info())
    out, err = capsys.readouterr()
    assert not out
    assert err == """an error occurred testing this code foo eggs
(pass -v for the full traceback)
FakeError: example
"""
    assert excinfo_arg_0(excinfo) == 8
Exemplo n.º 5
0
def test_verbose_errormark(capsys, app):
    app.verbose = True
    exc = FakeError('example')
    exc._errormark = 'testing this code {0} {spam}', 8, ('foo', 'bar'), {
        'spam': 'eggs'
    }
    try:
        raise exc
    except:
        exc_info = sys.exc_info()
    with pytest.raises(SystemExit) as excinfo:
        app.excepthook(*exc_info)
    tb_string = ''.join(traceback.format_exception(*exc_info))
    out, err = capsys.readouterr()
    assert not out
    assert err == 'an error occurred testing this code foo eggs\n' + tb_string
    assert excinfo_arg_0(excinfo) == 8
Exemplo n.º 6
0
def test_terse_errormark(capsys, app):
    app.verbose = False
    exc = FakeError('example')
    exc._errormark = 'testing this code {0} {spam}', 8, ('foo', 'bar'), {
        'spam': 'eggs'
    }
    try:
        raise exc
    except:
        with pytest.raises(SystemExit) as excinfo:
            app.excepthook(*sys.exc_info())
    out, err = capsys.readouterr()
    assert not out
    assert err == """an error occurred testing this code foo eggs
(pass -v for the full traceback)
FakeError: example
"""
    assert excinfo_arg_0(excinfo) == 8
Exemplo n.º 7
0
def test_site_remove_default_fails(app):
    with pytest.raises(SystemExit) as excinfo:
        app.main(['site', 'remove', 'default'])
    assert excinfo_arg_0(excinfo)
Exemplo n.º 8
0
 def test_no_args(self):
     with pytest.raises(SystemExit) as excinfo:
         self.app.main([])
     assert excinfo_arg_0(excinfo) == 2
Exemplo n.º 9
0
def test_site_remove_default_fails(app):
    with pytest.raises(SystemExit) as excinfo:
        app.main(['site', 'remove', 'default'])
    assert excinfo_arg_0(excinfo)
Exemplo n.º 10
0
 def test_no_args(self):
     with pytest.raises(SystemExit) as excinfo:
         self.app.main([])
     assert excinfo_arg_0(excinfo) == 2