Skip to content

Commit

Permalink
Merge pull request #2811 from greyli/test-routes-command-for-no-routes
Browse files Browse the repository at this point in the history
Add test for routes command when no routes registered
  • Loading branch information
davidism committed May 31, 2018
2 parents 0b4296f + 4025e27 commit b6a8f75
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,17 @@ def aaa_post():
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:]):
Expand Down Expand Up @@ -430,6 +441,11 @@ def test_all_methods(self, invoke):
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'
Expand Down

0 comments on commit b6a8f75

Please sign in to comment.