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
()
| 527 | |
| 528 | |
| 529 | def 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 | |
| 551 | def test_init_app_server_false_pattern(): |