Esempio n. 1
0
def test_run(app: Application, argv):
    app.catch_exceptions(False)
    app.auto_exits(False)
    command = Foo1Command()
    app.add(command)

    sys.argv = ["console", "foo bar1"]
    app.run()

    assert isinstance(command.io, IO)
    assert isinstance(command.io.output, StreamOutput)
    assert isinstance(command.io.error_output, StreamOutput)
    assert command.io.output.stream == sys.stdout
    assert command.io.error_output.stream == sys.stderr
Esempio n. 2
0
def test_set_catch_exceptions(app: Application, environ: Dict[str, str]):
    app.auto_exits(False)
    os.environ["COLUMNS"] = "120"

    tester = ApplicationTester(app)
    app.catch_exceptions(True)

    assert app.are_exceptions_caught()

    tester.execute("foo", decorated=False)

    assert tester.io.fetch_output() == ""
    assert (
        tester.io.fetch_error()
        == FIXTURES_PATH.joinpath("application_exception1.txt").read_text()
    )

    app.catch_exceptions(False)

    with pytest.raises(CommandNotFoundException):
        tester.execute("foo", decorated=False)
Esempio n. 3
0
def test_auto_exit(app: Application):
    app.auto_exits(False)
    assert not app.is_auto_exit_enabled()

    app.auto_exits()
    assert app.is_auto_exit_enabled()