Browse Source

Enhance tests.test_cli.test_find_best_app (#1882)

This commit adds a test case for `test_find_best_app` where
Module object does not contain Flask application.
Also cleans the function little bit to provides more meaningful comment.
pull/1925/merge
Hyunchel Kim 9 years ago committed by David Lord
parent
commit
f19d3bd67e
  1. 25
      tests/test_cli.py

25
tests/test_cli.py

@ -32,24 +32,27 @@ def test_cli_name(test_apps):
def test_find_best_app(test_apps):
"""Test of find_best_app."""
class mod:
"""Test if `find_best_app` behaves as expected with different combinations of input."""
class Module:
app = Flask('appname')
assert find_best_app(mod) == mod.app
assert find_best_app(Module) == Module.app
class mod:
class Module:
application = Flask('appname')
assert find_best_app(mod) == mod.application
assert find_best_app(Module) == Module.application
class mod:
class Module:
myapp = Flask('appname')
assert find_best_app(mod) == mod.myapp
assert find_best_app(Module) == Module.myapp
class mod:
myapp = Flask('appname')
myapp2 = Flask('appname2')
class Module:
pass
pytest.raises(NoAppException, find_best_app, Module)
pytest.raises(NoAppException, find_best_app, mod)
class Module:
myapp1 = Flask('appname1')
myapp2 = Flask('appname2')
pytest.raises(NoAppException, find_best_app, Module)
def test_prepare_exec_for_file(test_apps):

Loading…
Cancel
Save