MCPcopy Index your code
hub / github.com/plotly/dash / test_init_app_with_flask_run_pattern

Function test_init_app_with_flask_run_pattern

tests/unit/test_configs.py:529–548  ·  view source on GitHub ↗

Test that init_app works correctly with the flask run pattern. This tests the fix for https://github.com/plotly/dash/issues/3787 where using flask run would cause a ValueError about duplicate blueprint registration because init_app was called twice (once automatically in __init__ wi

()

Source from the content-addressed store, hash-verified

527
528
529def test_init_app_with_flask_run_pattern():
530 """Test that init_app works correctly with the flask run pattern.
531
532 This tests the fix for https://github.com/plotly/dash/issues/3787
533 where using flask run would cause a ValueError about duplicate blueprint
534 registration because init_app was called twice (once automatically in
535 __init__ with server=True, and once by the user in their create_app factory).
536 """
537 # Simulate the flask run pattern where:
538 # 1. Dash app is created with server=True (default)
539 # 2. User's create_app factory calls init_app with their Flask server
540 external_server = Flask("external_test")
541 app = Dash(__name__)
542
543 # This should NOT raise "ValueError: The name '_dash_assets' is already registered"
544 app.init_app(external_server)
545
546 # Verify the backend now uses the external server
547 assert app.server is external_server
548 assert app.backend.server is external_server
549
550
551def test_init_app_server_false_pattern():

Callers

nothing calls this directly

Calls 2

init_appMethod · 0.95
DashClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…