forked from orbit-oss/flask
Add test for find_default_import_path
This commit is contained in:
parent
6a3a209f41
commit
5eaed37116
1 changed files with 15 additions and 1 deletions
|
|
@ -21,7 +21,8 @@ from click.testing import CliRunner
|
|||
from flask import Flask, current_app
|
||||
|
||||
from flask.cli import AppGroup, FlaskGroup, NoAppException, ScriptInfo, \
|
||||
find_best_app, locate_app, with_appcontext, prepare_exec_for_file
|
||||
find_best_app, locate_app, with_appcontext, prepare_exec_for_file, \
|
||||
find_default_import_path
|
||||
|
||||
|
||||
def test_cli_name(test_apps):
|
||||
|
|
@ -79,6 +80,19 @@ def test_locate_app(test_apps):
|
|||
pytest.raises(RuntimeError, locate_app, "cliapp.app:notanapp")
|
||||
|
||||
|
||||
def test_find_default_import_path(test_apps, monkeypatch, tmpdir):
|
||||
"""Test of find_default_import_path."""
|
||||
monkeypatch.delitem(os.environ, 'FLASK_APP', raising=False)
|
||||
assert find_default_import_path() == None
|
||||
monkeypatch.setitem(os.environ, 'FLASK_APP', 'notanapp')
|
||||
assert find_default_import_path() == 'notanapp'
|
||||
tmpfile = tmpdir.join('testapp.py')
|
||||
tmpfile.write('')
|
||||
monkeypatch.setitem(os.environ, 'FLASK_APP', str(tmpfile))
|
||||
expect_rv = prepare_exec_for_file(str(tmpfile))
|
||||
assert find_default_import_path() == expect_rv
|
||||
|
||||
|
||||
def test_scriptinfo(test_apps):
|
||||
"""Test of ScriptInfo."""
|
||||
obj = ScriptInfo(app_import_path="cliapp.app:testapp")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue