Skip to content

Commit 3884843

Browse files
committed
cbsc001 flag percy snapshot before increase call count.
1 parent c23be81 commit 3884843

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tests/integration/callbacks/test_basic_callback.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import os
23
from multiprocessing import Lock, Value
34
import pytest
45
import time
@@ -37,17 +38,24 @@ def test_cbsc001_simple_callback(dash_duo):
3738
]
3839
)
3940
call_count = Value("i", 0)
41+
percy_ss = Value("b", False)
4042

4143
@app.callback(Output("output-1", "children"), [Input("input", "value")])
4244
def update_output(value):
4345
with lock:
44-
call_count.value = call_count.value + 1
46+
if not percy_ss.value:
47+
call_count.value = call_count.value + 1
4548
return value
4649

50+
def snapshot(name):
51+
percy_ss.value = os.getenv("PERCY_ENABLE", "") != ""
52+
dash_duo.percy_snapshot(name=name)
53+
percy_ss.value = False
54+
4755
dash_duo.start_server(app)
4856

4957
dash_duo.wait_for_text_to_equal("#output-1", "initial value")
50-
dash_duo.percy_snapshot(name="simple-callback-initial")
58+
snapshot("simple-callback-initial")
5159

5260
input_ = dash_duo.find_element("#input")
5361
dash_duo.clear_input(input_)
@@ -57,7 +65,7 @@ def update_output(value):
5765
input_.send_keys(key)
5866

5967
dash_duo.wait_for_text_to_equal("#output-1", "hello world")
60-
dash_duo.percy_snapshot(name="simple-callback-hello-world")
68+
snapshot("simple-callback-hello-world")
6169

6270
assert call_count.value == 2 + len("hello world"), "initial count + each key stroke"
6371

0 commit comments

Comments
 (0)