Beispiel #1
0
def test_cli_parse_not_found(runner, echo, app):
    """
    Ensures the parse command catches errors
    """
    ce = CompilerError(None)
    app.parse.side_effect = StoryError(ce, None)
    e = runner.invoke(Cli.parse, ['/a/non/existent/file'])
    assert e.exit_code == 1
    click.echo.assert_called_with(StoryError._internal_error(ce))
Beispiel #2
0
def test_cli_compile_not_found(patch, runner, echo, app):
    """
    Ensures the compile command catches errors
    """
    patch.object(StoryError, '_internal_error')
    ce = CompilerError(None)
    app.compile.side_effect = StoryError(ce, None)
    e = runner.invoke(Cli.compile, ['/a/non/existent/file'])
    assert e.exit_code == 1
    click.echo.assert_called_with(StoryError._internal_error())
Beispiel #3
0
def test_cli_parse_not_found(runner, echo, app, patch):
    """
    Ensures the parse command catches errors
    """
    patch.object(StoryError, "message")
    ce = CompilerError(None)
    app.parse.side_effect = StoryError(ce, None)
    e = runner.invoke(Cli.parse, ["/a/non/existent/file"])
    assert e.exit_code == 1
    click.echo.assert_called_with(StoryError.message())
Beispiel #4
0
def test_cli_lex_not_found(patch, runner, echo, app):
    """
    Ensures the lex command catches errors
    """
    patch.object(StoryError, 'message')
    ce = CompilerError(None)
    patch.object(App, 'lex')
    App.lex.side_effect = StoryError(ce, None)
    e = runner.invoke(Cli.lex, ['/a/non/existent/file'])
    assert e.exit_code == 1
    click.echo.assert_called_with(StoryError.message())
Beispiel #5
0
def test_cli_format_not_found(patch, runner, echo, app):
    """
    Ensures the format command catches errors
    """
    patch.object(StoryError, "message")
    ce = CompilerError(None)
    patch.object(App, "format")
    App.format.side_effect = StoryError(ce, None)
    e = runner.invoke(Cli.format, ["/a/non/existent/file"])
    assert e.exit_code == 1
    click.echo.assert_called_with(StoryError.message())
Beispiel #6
0
def test_cli_compile_not_found(runner, echo, app):
    """
    Ensures the compile command catches errors
    """
    ce = CompilerError(None, message='error')
    app.compile.side_effect = StoryError(ce, None)
    e = runner.invoke(Cli.compile, ['/a/non/existent/file'])
    assert e.exit_code == 1
    click.echo.assert_called_with('error')
Beispiel #7
0
def test_cli_compile_not_found_debug(runner, echo, app):
    """
    Ensures the compile command raises errors with debug=True
    """
    ce = CompilerError(None)
    app.compile.side_effect = StoryError(ce, None)
    e = runner.invoke(Cli.compile, ['--debug', '/a/non/existent/file'])
    assert e.exit_code == 1
    assert isinstance(e.exception, CompilerError)
    assert e.exception.message() == 'Unknown compiler error'
Beispiel #8
0
def test_cli_format_not_found_debug(patch, runner, echo, app):
    """
    Ensures the format command raises errors with debug=True
    """
    ce = CompilerError(None)
    patch.object(App, 'format')
    App.format.side_effect = StoryError(ce, None)
    e = runner.invoke(Cli.format, ['--debug', '/a/non/existent/file'])
    assert e.exit_code == 1
    assert isinstance(e.exception, CompilerError)
    assert e.exception.message() == 'Unknown compiler error'
Beispiel #9
0
def test_cli_lex_not_found_debug(patch, runner, echo, app):
    """
    Ensures the compile command raises errors with debug=True
    """
    ce = CompilerError(None, message='error')
    patch.object(App, 'lex')
    App.lex.side_effect = StoryError(ce, None)
    e = runner.invoke(Cli.lex, ['--debug', '/a/non/existent/file'])
    assert e.exit_code == 1
    assert isinstance(e.exception, StoryError)
    assert e.exception.short_message() == 'E0001: error'
Beispiel #10
0
def test_cli_parse_debug(runner, echo, app):
    """
    Ensures the parse command supports raises errors with debug=True
    """
    runner.invoke(Cli.parse, ['--debug'])
    ce = CompilerError(None, message='unexpected error')
    app.parse.side_effect = StoryError(ce, None)
    e = runner.invoke(Cli.parse, ['--debug', '/a/non/existent/file'])
    assert e.exit_code == 1
    assert isinstance(e.exception, StoryError)
    assert e.exception.short_message() == 'E0001: unexpected error'
Beispiel #11
0
def test_cli_lex_not_found_debug(patch, runner, echo, app):
    """
    Ensures the lex command raises errors with debug=True
    """
    ce = CompilerError(None)
    patch.object(App, "lex")
    App.lex.side_effect = StoryError(ce, None)
    e = runner.invoke(Cli.lex, ["--debug", "/a/non/existent/file"])
    assert e.exit_code == 1
    assert isinstance(e.exception, CompilerError)
    assert e.exception.message() == "Unknown compiler error"
Beispiel #12
0
def test_cli_parse_debug(runner, echo, app):
    """
    Ensures the parse command supports raises errors with debug=True
    """
    runner.invoke(Cli.parse, ["--debug"])
    ce = CompilerError(None)
    app.parse.side_effect = StoryError(ce, None)
    e = runner.invoke(Cli.parse, ["--debug", "/a/non/existent/file"])
    assert e.exit_code == 1
    assert isinstance(e.exception, CompilerError)
    assert e.exception.message() == "Unknown compiler error"