Reset Dash module-level state after each MCP test.
()
| 34 | |
| 35 | @pytest.fixture(autouse=True) |
| 36 | def _reset_dash_app_state(): |
| 37 | """Reset Dash module-level state after each MCP test.""" |
| 38 | initial_resources = list(_RESOURCE_PROVIDERS) |
| 39 | initial_tools = list(_TOOL_PROVIDERS) |
| 40 | initial_callbacks_default = CallbackTools.callbacks_mcp_enabled_by_default |
| 41 | initial_expose_docstrings = CallbackTools.expose_docstrings_by_default |
| 42 | |
| 43 | yield |
| 44 | |
| 45 | _RESOURCE_PROVIDERS[:] = initial_resources |
| 46 | _TOOL_PROVIDERS[:] = initial_tools |
| 47 | CallbackTools.callbacks_mcp_enabled_by_default = initial_callbacks_default |
| 48 | CallbackTools.expose_docstrings_by_default = initial_expose_docstrings |
| 49 | MCP_DECORATED_FUNCTIONS.clear() |
| 50 | _configure._current_config = dict(_configure._DEFAULT_CONFIG) |
| 51 | _get_app.APP = None |
| 52 | _get_app.app_context.set(None) |
| 53 | |
| 54 | |
| 55 | def _mcp_post(server_url, method, params=None, request_id=1): |