Skip to content
Myr

Merge pull request #1881 from antsar/master

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

Add test for find_default_import_path

authored by Markus Unterwaditzer · committed by Markus Unterwaditzer · parents b990d80, 5eaed37 · Browse files · 1 file+15 added−1 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+15 added−1 removed

  • tests:+15 added−1 removed

1 file+15 added−1 removed

modified:tests/test_cli.py+15 added-1 removed
19 unmodified lines
20from click.testing import CliRunner21from flask import Flask, current_app2223from flask.cli import AppGroup, FlaskGroup, NoAppException, ScriptInfo, \24 find_best_app, locate_app, with_appcontext, prepare_exec_for_file24 find_best_app, locate_app, with_appcontext, prepare_exec_for_file, \25 find_default_import_path262728def test_cli_name(test_apps):29 """Make sure the CLI object's name is the app's name and not the app itself"""
49 unmodified lines
79 assert locate_app("cliapp.multiapp:app1").name == "app1"80 pytest.raises(RuntimeError, locate_app, "cliapp.app:notanapp")818283def test_find_default_import_path(test_apps, monkeypatch, tmpdir):84 """Test of find_default_import_path."""85 monkeypatch.delitem(os.environ, 'FLASK_APP', raising=False)86 assert find_default_import_path() == None87 monkeypatch.setitem(os.environ, 'FLASK_APP', 'notanapp')88 assert find_default_import_path() == 'notanapp'89 tmpfile = tmpdir.join('testapp.py')90 tmpfile.write('')91 monkeypatch.setitem(os.environ, 'FLASK_APP', str(tmpfile))92 expect_rv = prepare_exec_for_file(str(tmpfile))93 assert find_default_import_path() == expect_rv949596def test_scriptinfo(test_apps):97 """Test of ScriptInfo."""98 obj = ScriptInfo(app_import_path="cliapp.app:testapp")99 assert obj.load_app().name == "testapp"
73 unmodified lines