From 4025e27b5714736657f0ac9548170e0ad285c53a Mon Sep 17 00:00:00 2001 From: Grey Li Date: Thu, 31 May 2018 11:43:51 +0800 Subject: [PATCH] Add test for routes command when no routes registered --- tests/test_cli.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_cli.py b/tests/test_cli.py index 387eeeba..f7ebc6bd 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -393,6 +393,17 @@ class TestRoutes: cli = FlaskGroup(create_app=create_app) return partial(runner.invoke, cli) + @pytest.fixture + def invoke_no_routes(self, runner): + def create_app(info): + app = Flask(__name__, static_folder=None) + app.testing = True + + return app + + cli = FlaskGroup(create_app=create_app) + return partial(runner.invoke, cli) + def expect_order(self, order, output): # skip the header and match the start of each row for expect, line in zip(order, output.splitlines()[2:]): @@ -430,6 +441,11 @@ class TestRoutes: output = invoke(['routes', '--all-methods']).output assert 'GET, HEAD, OPTIONS, POST' in output + def test_no_routes(self, invoke_no_routes): + result = invoke_no_routes(['routes']) + assert result.exit_code == 0 + assert 'No routes were registered.' in result.output + need_dotenv = pytest.mark.skipif( dotenv is None, reason='dotenv is not installed'