蓝图怎么单独测?端点名与 url_for 有什么规则?蓝图的钩子会不会影响别的路由?同一个蓝图能注册两次吗?这篇用一组真实运行的 pytest 用例把这些行为逐项验证。
test_route_and_prefix RESULT route 200 {'cfg': 'CNY', 'endpoint': 'shop.items', 'hook': 'ran', 'items': ['a', 'b'], 'self_url': '/shop/items'}
test_endpoint_name_has_blueprint_prefix RESULT url_for /shop/items /shop/3
test_hooks_only_for_blueprint RESULT hooks 1 None
test_blueprint_uses_app_config RESULT cfg CNY
test_register_with_other_prefix RESULT other-prefix 200 404
test_register_twice_needs_different_names RESULT twice ValueError: The name 'shop' is already registered for this blueprint. Use 'name=' to provide a unique
RESULT twice-named 200 200
test_isolated_app_only_this_blueprint RESULT isolated ['shop'] ['/shop/<int:i>', '/shop/items']
test_no_registration_means_404 RESULT unregistered 404
test_hook_effect_visible_through_g RESULT g ran
============================== 9 passed in 0.02s ===============================