@@ -352,7 +352,7 @@ def _calls_bad_cache(bad_cache_func, res_queue, trash_cache, separate_files):
352352 res_queue .put (exc )
353353
354354
355- def _helper_bad_cache_file (sleeptime , separate_files ):
355+ def _helper_bad_cache_file (sleep_time : float , separate_files : bool ):
356356 """Test pickle core handling of bad cache files."""
357357 _bad_cache_decorated = _get_decorated_func (
358358 _bad_cache , separate_files = separate_files
@@ -380,7 +380,7 @@ def _helper_bad_cache_file(sleeptime, separate_files):
380380 daemon = True ,
381381 )
382382 thread1 .start ()
383- sleep (sleeptime )
383+ sleep (sleep_time )
384384 thread2 .start ()
385385 thread1 .join (timeout = 2 )
386386 thread2 .join (timeout = 2 )
@@ -395,16 +395,17 @@ def _helper_bad_cache_file(sleeptime, separate_files):
395395
396396# we want this to succeed at least once
397397@pytest .mark .pickle
398- @pytest .mark .xfail
399398@pytest .mark .parametrize ("separate_files" , [True , False ])
400399def test_bad_cache_file (separate_files ):
401400 """Test pickle core handling of bad cache files."""
402- sleeptimes = [0.1 , 0.2 , 0.3 , 0.5 , 0.6 , 0.7 , 0.8 , 1 , 1.5 , 2 ]
403- sleeptimes = sleeptimes + sleeptimes
404- for sleeptime in sleeptimes :
405- if _helper_bad_cache_file (sleeptime , separate_files ):
406- return
407- raise AssertionError ()
401+ sleep_times = [0.1 , 0.2 , 0.3 , 0.5 , 0.6 , 0.7 , 0.8 , 1 , 1.5 , 2 ]
402+ bad_file = False
403+ for sleep_time in sleep_times * 2 :
404+ if _helper_bad_cache_file (sleep_time , separate_files ):
405+ bad_file = True
406+ break
407+ # it is expected that for separate_files=True files will not be bad
408+ assert bad_file is not separate_files
408409
409410
410411def _delete_cache (arg_1 , arg_2 ):
@@ -429,7 +430,9 @@ def _delete_cache(arg_1, arg_2):
429430}
430431
431432
432- def _calls_delete_cache (del_cache_func , res_queue , del_cache , separate_files ):
433+ def _calls_delete_cache (
434+ del_cache_func , res_queue , del_cache : bool , separate_files : bool
435+ ):
433436 try :
434437 # print('in')
435438 res = del_cache_func (0.13 , 0.02 )
@@ -443,7 +446,7 @@ def _calls_delete_cache(del_cache_func, res_queue, del_cache, separate_files):
443446 res_queue .put (exc )
444447
445448
446- def _helper_delete_cache_file (sleeptime , separate_files ):
449+ def _helper_delete_cache_file (sleep_time : float , separate_files : bool ):
447450 """Test pickle core handling of missing cache files."""
448451 _delete_cache_decorated = _get_decorated_func (
449452 _delete_cache , separate_files = separate_files
@@ -471,7 +474,7 @@ def _helper_delete_cache_file(sleeptime, separate_files):
471474 daemon = True ,
472475 )
473476 thread1 .start ()
474- sleep (sleeptime )
477+ sleep (sleep_time )
475478 thread2 .start ()
476479 thread1 .join (timeout = 2 )
477480 thread2 .join (timeout = 2 )
@@ -486,16 +489,17 @@ def _helper_delete_cache_file(sleeptime, separate_files):
486489
487490
488491@pytest .mark .pickle
489- @pytest .mark .xfail
490492@pytest .mark .parametrize ("separate_files" , [False , True ])
491493def test_delete_cache_file (separate_files ):
492494 """Test pickle core handling of missing cache files."""
493- sleeptimes = [0.1 , 0.2 , 0.3 , 0.5 , 0.7 , 1 ]
494- sleeptimes = sleeptimes * 4
495- for sleeptime in sleeptimes :
496- if _helper_delete_cache_file (sleeptime , separate_files ):
497- return
498- raise AssertionError ()
495+ sleep_times = [0.1 , 0.2 , 0.3 , 0.5 , 0.7 , 1 ]
496+ deleted = False
497+ for sleep_time in sleep_times * 4 :
498+ if _helper_delete_cache_file (sleep_time , separate_files ):
499+ deleted = True
500+ break
501+ # it is expected that for separate_files=True files will not be deleted
502+ assert deleted is not separate_files
499503
500504
501505@pytest .mark .pickle
0 commit comments