1414import requests
1515from cachecontrol import CacheControl
1616from cachecontrol .caches import FileCache , SeparateBodyFileCache
17- from filelock import FileLock
17+ from lockfile import LockFile
18+ from lockfile .mkdirlockfile import MkdirLockFile
1819
1920
2021def randomdata ():
@@ -93,10 +94,21 @@ def test_key_length(self, sess):
9394 assert len (self .cache .encode (url0 )) < 200
9495 assert len (self .cache .encode (url0 )) == len (self .cache .encode (url1 ))
9596
96- def test_simple_lockfile_arg (self , tmpdir ):
97- cache = self .FileCacheClass (str (tmpdir ))
98-
99- assert issubclass (cache .lock_class , FileLock )
97+ def test_cant_use_dir_and_lock_class (self , tmpdir ):
98+ with pytest .raises (ValueError ):
99+ self .FileCacheClass (str (tmpdir ), use_dir_lock = True , lock_class = object ())
100+
101+ @pytest .mark .parametrize (
102+ ("value" , "expected" ),
103+ [(None , LockFile ), (True , MkdirLockFile ), (False , LockFile )],
104+ )
105+ def test_simple_lockfile_arg (self , tmpdir , value , expected ):
106+ if value is not None :
107+ cache = self .FileCacheClass (str (tmpdir ), use_dir_lock = value )
108+ else :
109+ cache = self .FileCacheClass (str (tmpdir ))
110+
111+ assert issubclass (cache .lock_class , expected )
100112 cache .close ()
101113
102114 def test_lock_class (self , tmpdir ):
@@ -122,7 +134,7 @@ class TestFileCache(FileCacheTestsMixin):
122134 """
123135 Tests for ``FileCache``.
124136 """
125-
137+
126138 FileCacheClass = FileCache
127139
128140 def test_body_stored_inline (self , sess ):
0 commit comments