Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1affa9e

Browse files
committed
TST: Update some times for interactive timer test on CI
1 parent52a584d commit1affa9e

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

‎lib/matplotlib/tests/test_backends_interactive.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -675,11 +675,13 @@ def _impl_test_interactive_timers():
675675
assertmock_single_shot.call_count==1, \
676676
f"Singleshot: Expected 1 call, got{mock_single_shot.call_count}"
677677

678-
# 250ms timer triggers and the callback takes 150ms to run
679-
# Test that we don't drift and that we get called on every 250ms
680-
# firing and not every 400ms
681-
timer_repeating.interval=250
682-
mock_repeating.side_effect=lambda:time.sleep(0.15)
678+
# 500ms timer triggers and the callback takes 400ms to run
679+
# Test that we don't drift and that we get called on every 500ms
680+
# firing and not every 900ms
681+
timer_repeating.interval=500
682+
# sleep for 80% of the interval
683+
sleep_time=timer_repeating.interval/1000*0.8
684+
mock_repeating.side_effect=lambda:time.sleep(sleep_time)
683685
# calling start() again on a repeating timer should remove the old
684686
# one, so we don't want double the number of calls here either because
685687
# two timers are potentially running.
@@ -689,18 +691,21 @@ def _impl_test_interactive_timers():
689691
timer_single_shot.stop()
690692
timer_single_shot.start()
691693

692-
event_loop_time=2# in seconds
694+
# CI resources are inconsistent, so we need to allow for some slop
695+
event_loop_time=10ifos.getenv("CI")else3# in seconds
693696
expected_calls=int(event_loop_time/ (timer_repeating.interval/1000))
694697

695698
t_start=time.perf_counter()
696699
fig.canvas.start_event_loop(event_loop_time)
697700
t_loop=time.perf_counter()-t_start
698-
# Should be around 2s, but allow for some slop on CI. We want to make sure
699-
# we aren't getting 2 + (callback time) 0.5s/iteration, which would be 4+ s.
700-
assert1.8<t_loop<3, \
701-
f"Event loop: Expected to run for around 2s, but ran for{t_loop:.2f}s"
701+
# Should be around event_loop_time, but allow for some slop on CI.
702+
# We want to make sure we aren't getting
703+
# event_loop_time + (callback time)*niterations
704+
assertevent_loop_time*0.95<t_loop<event_loop_time/0.7, \
705+
f"Event loop: Expected to run for around{event_loop_time}s, " \
706+
f"but ran for{t_loop:.2f}s"
702707
# Not exact timers, so add some slop. (Quite a bit for CI resources)
703-
assertabs(mock_repeating.call_count-expected_calls)<=2, \
708+
assertabs(mock_repeating.call_count-expected_calls)/expected_calls<=0.3, \
704709
f"Slow callback: Expected{expected_calls} calls, " \
705710
f"got{mock_repeating.call_count}"
706711
assertmock_single_shot.call_count==2, \

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp