@@ -333,26 +333,6 @@ def test_get_expired_slow_path(cache):
333333 assert cache .get (0 ) is None
334334
335335
336- def test_get_ioerror_slow_path (cache ):
337- cache .reset ('eviction_policy' , 'least-recently-used' )
338- cache .set (0 , 0 )
339-
340- disk = mock .Mock ()
341- put = mock .Mock ()
342- fetch = mock .Mock ()
343-
344- disk .put = put
345- put .side_effect = [(0 , True )]
346- disk .fetch = fetch
347- io_error = IOError ()
348- io_error .errno = errno .EACCES
349- fetch .side_effect = io_error
350-
351- with mock .patch .object (cache , '_disk' , disk ):
352- with pytest .raises (IOError ):
353- cache .get (0 )
354-
355-
356336def test_pop (cache ):
357337 assert cache .incr ('alpha' ) == 1
358338 assert cache .pop ('alpha' ) == 1
@@ -396,25 +376,6 @@ def test_pop_ioerror(cache):
396376 assert cache .pop (0 ) is None
397377
398378
399- def test_pop_ioerror_eacces (cache ):
400- assert cache .set (0 , 0 )
401-
402- disk = mock .Mock ()
403- put = mock .Mock ()
404- fetch = mock .Mock ()
405-
406- disk .put = put
407- put .side_effect = [(0 , True )]
408- disk .fetch = fetch
409- io_error = IOError ()
410- io_error .errno = errno .EACCES
411- fetch .side_effect = io_error
412-
413- with mock .patch .object (cache , '_disk' , disk ):
414- with pytest .raises (IOError ):
415- cache .pop (0 )
416-
417-
418379def test_delete (cache ):
419380 cache [0 ] = 0
420381 assert cache .delete (0 )
@@ -591,29 +552,6 @@ def test_least_frequently_used(cache):
591552 assert len (cache .check ()) == 0
592553
593554
594- def test_filename_error (cache ):
595- func = mock .Mock (side_effect = OSError (errno .EACCES ))
596-
597- with mock .patch ('os.makedirs' , func ):
598- with pytest .raises (OSError ):
599- cache ._disk .filename ()
600-
601-
602- def test_remove_error (cache ):
603- func = mock .Mock (side_effect = OSError (errno .EACCES ))
604-
605- try :
606- with mock .patch ('os.remove' , func ):
607- cache ._disk .remove ('ab/cd/efg.val' )
608- except OSError :
609- pass
610- else :
611- if os .name == 'nt' :
612- pass # File delete errors ignored on Windows.
613- else :
614- raise Exception ('test_remove_error failed' )
615-
616-
617555def test_check (cache ):
618556 blob = b'a' * 2 ** 20
619557 keys = (0 , 1 , 1234 , 56.78 , u'hello' , b'world' , None )
@@ -1028,44 +966,6 @@ def test_peek_ioerror(cache):
1028966 assert value == 0
1029967
1030968
1031- def test_pull_ioerror_eacces (cache ):
1032- assert cache .push (0 ) == 500000000000000
1033-
1034- disk = mock .Mock ()
1035- put = mock .Mock ()
1036- fetch = mock .Mock ()
1037-
1038- disk .put = put
1039- put .side_effect = [(0 , True )]
1040- disk .fetch = fetch
1041- io_error = IOError ()
1042- io_error .errno = errno .EACCES
1043- fetch .side_effect = io_error
1044-
1045- with mock .patch .object (cache , '_disk' , disk ):
1046- with pytest .raises (IOError ):
1047- cache .pull ()
1048-
1049-
1050- def test_peek_ioerror_eacces (cache ):
1051- assert cache .push (0 ) == 500000000000000
1052-
1053- disk = mock .Mock ()
1054- put = mock .Mock ()
1055- fetch = mock .Mock ()
1056-
1057- disk .put = put
1058- put .side_effect = [(0 , True )]
1059- disk .fetch = fetch
1060- io_error = IOError ()
1061- io_error .errno = errno .EACCES
1062- fetch .side_effect = io_error
1063-
1064- with mock .patch .object (cache , '_disk' , disk ):
1065- with pytest .raises (IOError ):
1066- cache .peek ()
1067-
1068-
1069969def test_peekitem_extras (cache ):
1070970 with pytest .raises (KeyError ):
1071971 cache .peekitem ()
@@ -1117,27 +1017,6 @@ def test_peekitem_ioerror(cache):
11171017 assert value == 2
11181018
11191019
1120- def test_peekitem_ioerror_eacces (cache ):
1121- assert cache .set ('a' , 0 )
1122- assert cache .set ('b' , 1 )
1123- assert cache .set ('c' , 2 )
1124-
1125- disk = mock .Mock ()
1126- put = mock .Mock ()
1127- fetch = mock .Mock ()
1128-
1129- disk .put = put
1130- put .side_effect = [(0 , True )]
1131- disk .fetch = fetch
1132- io_error = IOError ()
1133- io_error .errno = errno .EACCES
1134- fetch .side_effect = io_error
1135-
1136- with mock .patch .object (cache , '_disk' , disk ):
1137- with pytest .raises (IOError ):
1138- cache .peekitem ()
1139-
1140-
11411020def test_iterkeys (cache ):
11421021 assert list (cache .iterkeys ()) == []
11431022
0 commit comments