[go: nahoru, domu]

Skip to content

Commit

Permalink
Use lock instead of sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
T4rk1n committed Jun 11, 2024
1 parent f7d5f2c commit 2be6047
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions tests/integration/callbacks/test_wildcards.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
from selenium.webdriver.common.keys import Keys
import json
import time
from multiprocessing import Lock

from dash.testing import wait
import dash
Expand Down Expand Up @@ -556,6 +556,7 @@ def update_selected_values(values):


def test_cbwc008_running_match(dash_duo):
lock = Lock()
app = dash.Dash()

app.layout = [
Expand Down Expand Up @@ -590,21 +591,24 @@ def test_cbwc008_running_match(dash_duo):
prevent_initial_call=True,
)
def on_click(_) -> str:
time.sleep(1)
return "done"
with lock:
return "done"

dash_duo.start_server(app)

for i in range(1, 3):
dash_duo.find_element(f"#buttons button:nth-child({i})").click()
dash_duo.wait_for_text_to_equal(f"#buttons button:nth-child({i})", "running")
# verify all the buttons were disabled.
assert dash_duo.find_element("#buttons button:nth-child(1)").get_attribute(
"disabled"
)
assert dash_duo.find_element("#buttons button:nth-child(2)").get_attribute(
"disabled"
)
with lock:
dash_duo.find_element(f"#buttons button:nth-child({i})").click()
dash_duo.wait_for_text_to_equal(
f"#buttons button:nth-child({i})", "running"
)
# verify all the buttons were disabled.
assert dash_duo.find_element("#buttons button:nth-child(1)").get_attribute(
"disabled"
)
assert dash_duo.find_element("#buttons button:nth-child(2)").get_attribute(
"disabled"
)

dash_duo.wait_for_text_to_equal(f"#output{i}", "done")
dash_duo.wait_for_text_to_equal(f"#buttons button:nth-child({i})", "finished")
Expand Down

0 comments on commit 2be6047

Please sign in to comment.