Browse Source

Merge pull request #2811 from greyli/test-routes-command-for-no-routes

Add test for routes command when no routes registered
pull/2826/head
David Lord 7 years ago committed by GitHub
parent
commit
b6a8f75c70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      tests/test_cli.py

16
tests/test_cli.py

@ -393,6 +393,17 @@ class TestRoutes:
cli = FlaskGroup(create_app=create_app) cli = FlaskGroup(create_app=create_app)
return partial(runner.invoke, cli) 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): def expect_order(self, order, output):
# skip the header and match the start of each row # skip the header and match the start of each row
for expect, line in zip(order, output.splitlines()[2:]): for expect, line in zip(order, output.splitlines()[2:]):
@ -430,6 +441,11 @@ class TestRoutes:
output = invoke(['routes', '--all-methods']).output output = invoke(['routes', '--all-methods']).output
assert 'GET, HEAD, OPTIONS, POST' in 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( need_dotenv = pytest.mark.skipif(
dotenv is None, reason='dotenv is not installed' dotenv is None, reason='dotenv is not installed'

Loading…
Cancel
Save