Skip to content
Myr

Added runner fixture

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kiss György · committed by Kiss György · parent b8e826c · Browse files · 1 file+11 added−12 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+11 added−12 removed

  • tests:+11 added−12 removed

1 file+11 added−12 removed

modified:tests/test_cli.py+11 added-12 removed
23 unmodified lines
24 find_best_app, locate_app, with_appcontext, prepare_exec_for_file, \25 find_default_import_path262728@pytest.fixture29def runner():30 return CliRunner()313233def test_cli_name(test_apps):34 """Make sure the CLI object's name is the app's name and not the app itself"""35 from cliapp.app import testapp36 assert testapp.cli.name == testapp.name
75 unmodified lines
112 assert app.name == "createapp"113 assert obj.load_app() == app114115111def test_with_appcontext():116def test_with_appcontext(runner):117 """Test of with_appcontext."""118 @click.command()119 @with_appcontext120 def testcmd():121 click.echo(current_app.name)122123 obj = ScriptInfo(create_app=lambda info: Flask("testapp"))124120 runner = CliRunner()125 result = runner.invoke(testcmd, obj=obj)126 assert result.exit_code == 0127 assert result.output == 'testapp\n'128129126def test_appgroup():130def test_appgroup(runner):131 """Test of with_appcontext."""132 @click.group(cls=AppGroup)133 def cli():134 pass
11 unmodified lines
146 click.echo(current_app.name)147148 obj = ScriptInfo(create_app=lambda info: Flask("testappgroup"))149146 runner = CliRunner()150 result = runner.invoke(cli, ['test'], obj=obj)151 assert result.exit_code == 0152 assert result.output == 'testappgroup\n'153
1 unmodified line
155 assert result.exit_code == 0156 assert result.output == 'testappgroup\n'157158156def test_flaskgroup():159def test_flaskgroup(runner):160 """Test FlaskGroup."""161 def create_app(info):162 return Flask("flaskgroup")163
4 unmodified lines
168 @cli.command()169 def test():170 click.echo(current_app.name)171169 runner = CliRunner()172 result = runner.invoke(cli, ['test'])173 assert result.exit_code == 0174 assert result.output == 'flaskgroup\n'175176177class TestRoutes:176 def test_no_route(self, monkeypatch):178 def test_no_route(self, runner, monkeypatch):179 monkeypatch.setitem(os.environ, 'FLASK_APP', 'cliapp.routesapp:noroute_app')178 runner = CliRunner()180 result = runner.invoke(cli, ['routes'], catch_exceptions=False)181 assert result.exit_code == 0182 assert result.output == """\183Route Endpoint Methods 184-----------------------------------------------------185/static/<path:filename> static HEAD, OPTIONS, GET186"""187187 def test_simple_route(self, monkeypatch):188 def test_simple_route(self, runner, monkeypatch):189 monkeypatch.setitem(os.environ, 'FLASK_APP', 'cliapp.routesapp:simpleroute_app')189 runner = CliRunner()190 result = runner.invoke(cli, ['routes'], catch_exceptions=False)191 assert result.exit_code == 0192 assert result.output == """\193Route Endpoint Methods
1 unmodified line
195/simpleroute simple HEAD, OPTIONS, GET196/static/<path:filename> static HEAD, OPTIONS, GET197"""198199 def test_only_POST_route(self, monkeypatch):199 def test_only_POST_route(self, runner, monkeypatch):200 monkeypatch.setitem(os.environ, 'FLASK_APP', 'cliapp.routesapp:only_POST_route_app')201 runner = CliRunner()201 result = runner.invoke(cli, ['routes'], catch_exceptions=False)202 assert result.exit_code == 0203 assert result.output == """\204Route Endpoint Methods
4 unmodified lines