From f19d3bd67e0d8213013cf06f47d951c8735515c8 Mon Sep 17 00:00:00 2001 From: Hyunchel Kim Date: Tue, 5 Jul 2016 14:46:01 -0500 Subject: [PATCH] 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. --- tests/test_cli.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 4a3d0831..3f2cceab 100644 --- a/tests/test_cli.py +++ b/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):