Skip to content

Commit b6a8f75

Browse files
authored
Merge pull request pallets#2811 from greyli/test-routes-command-for-no-routes
Add test for routes command when no routes registered
2 parents 0b4296f + 4025e27 commit b6a8f75

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_cli.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,17 @@ def aaa_post():
393393
cli = FlaskGroup(create_app=create_app)
394394
return partial(runner.invoke, cli)
395395

396+
@pytest.fixture
397+
def invoke_no_routes(self, runner):
398+
def create_app(info):
399+
app = Flask(__name__, static_folder=None)
400+
app.testing = True
401+
402+
return app
403+
404+
cli = FlaskGroup(create_app=create_app)
405+
return partial(runner.invoke, cli)
406+
396407
def expect_order(self, order, output):
397408
# skip the header and match the start of each row
398409
for expect, line in zip(order, output.splitlines()[2:]):
@@ -430,6 +441,11 @@ def test_all_methods(self, invoke):
430441
output = invoke(['routes', '--all-methods']).output
431442
assert 'GET, HEAD, OPTIONS, POST' in output
432443

444+
def test_no_routes(self, invoke_no_routes):
445+
result = invoke_no_routes(['routes'])
446+
assert result.exit_code == 0
447+
assert 'No routes were registered.' in result.output
448+
433449

434450
need_dotenv = pytest.mark.skipif(
435451
dotenv is None, reason='dotenv is not installed'

0 commit comments

Comments
 (0)