MCPcopy
hub / github.com/pallets/flask / test_cli_blueprints

Function test_cli_blueprints

tests/test_cli.py:648–688  ·  view source on GitHub ↗

Test blueprint commands register correctly to the application

(app)

Source from the content-addressed store, hash-verified

646
647
648def test_cli_blueprints(app):
649 """Test blueprint commands register correctly to the application"""
650 custom = Blueprint("custom", __name__, cli_group="customized")
651 nested = Blueprint("nested", __name__)
652 merged = Blueprint("merged", __name__, cli_group=None)
653 late = Blueprint("late", __name__)
654
655 @custom.cli.command("custom")
656 def custom_command():
657 click.echo("custom_result")
658
659 @nested.cli.command("nested")
660 def nested_command():
661 click.echo("nested_result")
662
663 @merged.cli.command("merged")
664 def merged_command():
665 click.echo("merged_result")
666
667 @late.cli.command("late")
668 def late_command():
669 click.echo("late_result")
670
671 app.register_blueprint(custom)
672 app.register_blueprint(nested)
673 app.register_blueprint(merged)
674 app.register_blueprint(late, cli_group="late_registration")
675
676 app_runner = app.test_cli_runner()
677
678 result = app_runner.invoke(args=["customized", "custom"])
679 assert "custom_result" in result.output
680
681 result = app_runner.invoke(args=["nested", "nested"])
682 assert "nested_result" in result.output
683
684 result = app_runner.invoke(args=["merged"])
685 assert "merged_result" in result.output
686
687 result = app_runner.invoke(args=["late_registration", "late"])
688 assert "late_result" in result.output
689
690
691def test_cli_empty(app):

Callers

nothing calls this directly

Calls 4

BlueprintClass · 0.90
test_cli_runnerMethod · 0.80
register_blueprintMethod · 0.45
invokeMethod · 0.45

Tested by

no test coverage detected