1
+ import time
2
+ from multiprocessing import Value
3
+
1
4
from dash import Dash , Input , Output , html , set_props , register_page
2
5
3
6
@@ -30,28 +33,39 @@ def on_click(n_clicks):
30
33
def test_arb002_no_output_callbacks (dash_duo ):
31
34
app = Dash ()
32
35
36
+ counter = Value ("i" , 0 )
37
+
33
38
app .layout = html .Div (
34
39
[
35
40
html .Div (id = "secondary-output" ),
36
41
html .Button ("no-output" , id = "no-output" ),
37
42
html .Button ("no-output2" , id = "no-output2" ),
43
+ html .Button ("no-output3" , id = "no-output3" ),
38
44
]
39
45
)
40
46
41
47
@app .callback (
42
48
Input ("no-output" , "n_clicks" ),
43
49
prevent_initial_call = True ,
44
50
)
45
- def no_output (_ ):
51
+ def no_output1 (_ ):
46
52
set_props ("secondary-output" , {"children" : "no-output" })
47
53
48
54
@app .callback (
49
55
Input ("no-output2" , "n_clicks" ),
50
56
prevent_initial_call = True ,
51
57
)
52
- def no_output (_ ):
58
+ def no_output2 (_ ):
53
59
set_props ("secondary-output" , {"children" : "no-output2" })
54
60
61
+ @app .callback (
62
+ Input ("no-output3" , "n_clicks" ),
63
+ prevent_initial_call = True ,
64
+ )
65
+ def no_output3 (_ ):
66
+ with counter .get_lock ():
67
+ counter .value += 1
68
+
55
69
dash_duo .start_server (app )
56
70
57
71
dash_duo .wait_for_element ("#no-output" ).click ()
@@ -60,6 +74,12 @@ def no_output(_):
60
74
dash_duo .wait_for_element ("#no-output2" ).click ()
61
75
dash_duo .wait_for_text_to_equal ("#secondary-output" , "no-output2" )
62
76
77
+ dash_duo .wait_for_element ("#no-output3" ).click ()
78
+
79
+ time .sleep (1 )
80
+ with counter .get_lock ():
81
+ assert counter .value == 1
82
+
63
83
64
84
def test_arb003_arbitrary_pages (dash_duo ):
65
85
app = Dash (use_pages = True , pages_folder = "" )
0 commit comments