@@ -59,7 +59,8 @@ def test_init_wait_time_timeout(self):
5959 end_time = time .time ()
6060 elapsed_time = end_time - start_time
6161 self .assertEqual (config , None )
62- self .assertGreaterEqual (elapsed_time , 1 )
62+ wait_tolerance = 0.1
63+ self .assertGreaterEqual (elapsed_time , 1 - wait_tolerance )
6364 self .assertLess (elapsed_time , 2 )
6465 cache_policy .close ()
6566
@@ -69,7 +70,7 @@ def test_fetch_call_count(self):
6970 cache_policy = ConfigService ('' , PollingMode .auto_poll (poll_interval_seconds = 2 ,
7071 max_init_wait_time_seconds = 1 ),
7172 Hooks (), config_fetcher , log , config_cache , False )
72- wait_tolerance = 0.1
73+ wait_tolerance = 0.3
7374 time .sleep (3 + wait_tolerance )
7475 self .assertEqual (config_fetcher .get_call_count , 2 )
7576 config , _ = cache_policy .get_config ()
@@ -126,7 +127,8 @@ def test_rerun(self):
126127 cache_policy = ConfigService ('' , PollingMode .auto_poll (poll_interval_seconds = 2 ,
127128 max_init_wait_time_seconds = 5 ),
128129 Hooks (), config_fetcher , log , config_cache , False )
129- time .sleep (2.200 )
130+ wait_tolerance = 0.4
131+ time .sleep (2 + wait_tolerance )
130132 self .assertEqual (config_fetcher .get_call_count , 2 )
131133 cache_policy .close ()
132134
@@ -141,13 +143,14 @@ def test_callback(self):
141143 max_init_wait_time_seconds = 5 ),
142144 hooks , config_fetcher , log , config_cache , False )
143145 time .sleep (1 )
146+ wait_tolerance = 0.3
144147 self .assertEqual (config_fetcher .get_call_count , 1 )
145148 self .assertEqual (hook_callbacks .changed_config_call_count , 1 )
146- time .sleep (1.2 )
149+ time .sleep (1 + wait_tolerance )
147150 self .assertEqual (config_fetcher .get_call_count , 2 )
148151 self .assertEqual (hook_callbacks .changed_config_call_count , 1 )
149152 config_fetcher .set_configuration_json (TEST_JSON2 )
150- time .sleep (2.2 )
153+ time .sleep (2 + wait_tolerance )
151154 self .assertEqual (config_fetcher .get_call_count , 3 )
152155 self .assertEqual (hook_callbacks .changed_config_call_count , 2 )
153156 cache_policy .close ()
@@ -162,14 +165,15 @@ def test_callback_exception(self):
162165 cache_policy = ConfigService ('' , PollingMode .auto_poll (poll_interval_seconds = 2 ,
163166 max_init_wait_time_seconds = 5 ),
164167 hooks , config_fetcher , log , config_cache , False )
168+ wait_tolerance = 0.4
165169 time .sleep (1 )
166170 self .assertEqual (config_fetcher .get_call_count , 1 )
167171 self .assertEqual (hook_callbacks .callback_exception_call_count , 1 )
168- time .sleep (1.2 )
172+ time .sleep (1 + wait_tolerance )
169173 self .assertEqual (config_fetcher .get_call_count , 2 )
170174 self .assertEqual (hook_callbacks .callback_exception_call_count , 1 )
171175 config_fetcher .set_configuration_json (TEST_JSON2 )
172- time .sleep (2.2 )
176+ time .sleep (2 + wait_tolerance )
173177 self .assertEqual (config_fetcher .get_call_count , 3 )
174178 self .assertEqual (hook_callbacks .callback_exception_call_count , 2 )
175179 cache_policy .close ()
@@ -232,7 +236,8 @@ def test_return_cached_config_when_cache_is_not_expired(self):
232236 self .assertEqual (config_fetcher .get_call_count , 0 )
233237 self .assertEqual (config_fetcher .get_fetch_count , 0 )
234238
235- time .sleep (3 )
239+ wait_tolerance = 0.1
240+ time .sleep (3 + wait_tolerance )
236241
237242 config , _ = cache_policy .get_config ()
238243 settings = config .get (FEATURE_FLAGS )
0 commit comments