@@ -50,7 +50,9 @@ def for_config(cls, config):
5050
5151 @staticmethod
5252 def cache_dir_from_config (config ):
53- return resolve_from_str (config .getini ("cache_dir" ), config .rootdir )
53+ return resolve_from_str (
54+ config .getini ("cache_dir" ), str (config .rootdir )
55+ )
5456
5557 def warn (self , fmt , ** args ):
5658 from _pytest .warnings import _issue_warning_captured
@@ -76,7 +78,8 @@ def makedir(self, name):
7678 if len (name .parts ) > 1 :
7779 raise ValueError ("name is not allowed to contain path separators" )
7880 res = self ._cachedir .joinpath ("d" , name )
79- res .mkdir (exist_ok = True , parents = True )
81+ if not res .is_dir ():
82+ os .makedirs (str (res ))
8083 return py .path .local (res )
8184
8285 def _getvaluepath (self , key ):
@@ -115,7 +118,7 @@ def set(self, key, value):
115118 cache_dir_exists_already = True
116119 else :
117120 cache_dir_exists_already = self ._cachedir .exists ()
118- path .parent . mkdir ( exist_ok = True , parents = True )
121+ os . makedirs ( str ( path .parent ) )
119122 except (IOError , OSError ):
120123 self .warn ("could not create cache path {path}" , path = path )
121124 return
@@ -132,14 +135,17 @@ def set(self, key, value):
132135 def _ensure_supporting_files (self ):
133136 """Create supporting files in the cache dir that are not really part of the cache."""
134137 readme_path = self ._cachedir / "README.md"
135- readme_path .write_text (README_CONTENT )
138+ with readme_path .open ("w" ) as f :
139+ f .write (README_CONTENT )
136140
137141 gitignore_path = self ._cachedir .joinpath (".gitignore" )
138142 msg = "# Created by pytest automatically.\n *"
139- gitignore_path .write_text (msg , encoding = "UTF-8" )
143+ with gitignore_path .open ("w" , encoding = "UTF-8" ) as f :
144+ f .write (msg )
140145
141146 cachedir_tag_path = self ._cachedir .joinpath ("CACHEDIR.TAG" )
142- cachedir_tag_path .write_bytes (CACHEDIR_TAG_CONTENT )
147+ with cachedir_tag_path .open ("wb" ) as f :
148+ f .write (CACHEDIR_TAG_CONTENT )
143149
144150
145151class LFPlugin :
@@ -385,7 +391,7 @@ def pytest_report_header(config):
385391 # starting with .., ../.. if sensible
386392
387393 try :
388- displaypath = cachedir .relative_to (config .rootdir )
394+ displaypath = cachedir .relative_to (str ( config .rootdir ) )
389395 except ValueError :
390396 displaypath = cachedir
391397 return "cachedir: {}" .format (displaypath )
0 commit comments