Skip to content

Commit c4795ed

Browse files
committed
fixes for failing tests
1 parent c43a583 commit c4795ed

5 files changed

Lines changed: 15 additions & 14 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,4 @@ packages/
9393
!components/dash-core-components/tests/integration/upload/upload-assets/upft001.csv
9494
!components/dash-table/tests/assets/*.csv
9595
!components/dash-table/tests/selenium/assets/*.csv
96+
dash_config.json

dash/backends/_fastapi.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def get_current_request() -> Request:
5252
class CurrentRequestMiddleware:
5353
def __init__(self, app: ASGIApp) -> None: # type: ignore[name-defined]
5454
self.app = app
55+
print('loaded CurrentRequestMiddleware')
5556

5657
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: # type: ignore[name-defined]
5758
# non-http/ws scopes pass through (lifespan etc.)
@@ -100,7 +101,6 @@ def __call__(self, *args: Any, **kwargs: Any):
100101
@staticmethod
101102
def create_app(name: str = "__main__", config: Dict[str, Any] | None = None):
102103
app = FastAPI()
103-
app.add_middleware(CurrentRequestMiddleware)
104104

105105
if config:
106106
for key, value in config.items():
@@ -257,7 +257,7 @@ def setup_catchall(self, dash_app: Dash):
257257
@self.server.on_event("startup")
258258
def _setup_catchall():
259259
dash_app.enable_dev_tools(
260-
**self.config, first_run=False
260+
**load_config(), first_run=False
261261
) # do this to make sure dev tools are enabled
262262

263263
async def catchall(request: Request):
@@ -289,6 +289,7 @@ def add_url_rule(
289289

290290
def before_request(self, func: Callable[[], Any] | None):
291291
# FastAPI does not have before_request, but we can use middleware
292+
self.server.add_middleware(CurrentRequestMiddleware)
292293
self.server.middleware("http")(self._make_before_middleware(func))
293294

294295
def after_request(self, func: Callable[[], Any] | None):

dash/dash.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,11 +1944,10 @@ def enable_dev_tools(
19441944
jupyter_dash.configure_callback_exception_handling(
19451945
self, dev_tools.prune_errors
19461946
)
1947-
elif dev_tools.prune_errors:
1948-
secret = gen_salt(20)
1949-
self.backend.register_prune_error_handler(
1950-
secret, dev_tools.prune_errors
1951-
)
1947+
secret = gen_salt(20)
1948+
self.backend.register_prune_error_handler(
1949+
secret, dev_tools.prune_errors
1950+
)
19521951

19531952
if debug and dev_tools.ui:
19541953
self.backend.register_timing_hooks(first_run)

dash_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"debug": true, "dev_tools_ui": true, "dev_tools_props_check": true, "dev_tools_serve_dev_bundles": true, "dev_tools_hot_reload": true, "dev_tools_silence_routes_logging": true, "dev_tools_prune_errors": true, "dev_tools_hot_reload_interval": 3.0, "dev_tools_hot_reload_watch_interval": 0.5, "dev_tools_hot_reload_max_retry": 8, "dev_tools_disable_version_check": false}
1+
{"dev_tools_ui": false, "dev_tools_props_check": false, "dev_tools_serve_dev_bundles": false, "dev_tools_hot_reload": false, "dev_tools_silence_routes_logging": false, "dev_tools_prune_errors": false, "dev_tools_hot_reload_interval": 3.0, "dev_tools_hot_reload_watch_interval": 0.5, "dev_tools_hot_reload_max_retry": 8, "dev_tools_disable_version_check": true}

tests/backend_tests/test_preconfig_backends.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def update_output(value):
3030

3131
dash_duo.start_server(app)
3232
dash_duo.wait_for_text_to_equal("#output", f"You typed: {input_value}")
33-
dash_duo.find_element("#input").clear()
33+
dash_duo.clear_input(dash_duo.find_element("#input"))
3434
dash_duo.find_element("#input").send_keys(f"{backend.title()} Test")
3535
dash_duo.wait_for_text_to_equal("#output", f"You typed: {backend.title()} Test")
3636
assert dash_duo.get_logs() == []
@@ -93,7 +93,7 @@ def get_error_html(dash_duo, index):
9393
"dev_tools_prune_errors": False,
9494
"reload": False,
9595
},
96-
"fastapi.py",
96+
"_fastapi.py",
9797
),
9898
(
9999
"quart",
@@ -104,7 +104,7 @@ def get_error_html(dash_duo, index):
104104
"dev_tools_hot_reload": False,
105105
"dev_tools_prune_errors": False,
106106
},
107-
"quart.py",
107+
"_quart.py",
108108
),
109109
],
110110
)
@@ -131,7 +131,7 @@ def error_callback(n):
131131
error0 = get_error_html(dash_duo, 0)
132132
assert "in error_callback" in error0
133133
assert "ZeroDivisionError" in error0
134-
assert "backend" in error0 and error_msg in error0
134+
assert "backends/" in error0 and error_msg in error0
135135

136136

137137
@pytest.mark.parametrize(
@@ -173,7 +173,7 @@ def error_callback(n):
173173
error0 = get_error_html(dash_duo, 0)
174174
assert "in error_callback" in error0
175175
assert "ZeroDivisionError" in error0
176-
assert "dash/backend" not in error0 and error_msg not in error0
176+
assert "dash/backends/" not in error0 and error_msg not in error0
177177

178178

179179
@pytest.mark.parametrize(
@@ -209,7 +209,7 @@ def update_output_bg(value):
209209

210210
dash_duo.start_server(app)
211211
dash_duo.wait_for_text_to_equal("#output", f"Background typed: {input_value}")
212-
dash_duo.find_element("#input").clear()
212+
dash_duo.clear_input(dash_duo.find_element("#input"))
213213
dash_duo.find_element("#input").send_keys(f"{backend.title()} BG Test")
214214
dash_duo.wait_for_text_to_equal(
215215
"#output", f"Background typed: {backend.title()} BG Test"

0 commit comments

Comments
 (0)