Merge pull request #2811 from greyli/test-routes-command-for-no-routes
Add test for routes command when no routes registered
This commit is contained in:
commit
b6a8f75c70
1 changed files with 16 additions and 0 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue