@@ -50,7 +50,7 @@ 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 (config .getini ("cache_dir" ), str ( config .rootdir ) )
5454
5555    def  warn (self , fmt , ** args ):
5656        from  _pytest .warnings  import  _issue_warning_captured 
@@ -76,7 +76,8 @@ def makedir(self, name):
7676        if  len (name .parts ) >  1 :
7777            raise  ValueError ("name is not allowed to contain path separators" )
7878        res  =  self ._cachedir .joinpath ("d" , name )
79-         res .mkdir (exist_ok = True , parents = True )
79+         if  not  res .is_dir ():
80+             os .makedirs (str (res ))
8081        return  py .path .local (res )
8182
8283    def  _getvaluepath (self , key ):
@@ -115,7 +116,7 @@ def set(self, key, value):
115116                cache_dir_exists_already  =  True 
116117            else :
117118                cache_dir_exists_already  =  self ._cachedir .exists ()
118-                 path .parent . mkdir ( exist_ok = True ,  parents = True )
119+                 os . makedirs ( str ( path .parent ) )
119120        except  (IOError , OSError ):
120121            self .warn ("could not create cache path {path}" , path = path )
121122            return 
@@ -132,14 +133,17 @@ def set(self, key, value):
132133    def  _ensure_supporting_files (self ):
133134        """Create supporting files in the cache dir that are not really part of the cache.""" 
134135        readme_path  =  self ._cachedir  /  "README.md" 
135-         readme_path .write_text (README_CONTENT )
136+         with  readme_path .open ("w" ) as  f :
137+             f .write (README_CONTENT )
136138
137139        gitignore_path  =  self ._cachedir .joinpath (".gitignore" )
138140        msg  =  "# Created by pytest automatically.\n *" 
139-         gitignore_path .write_text (msg , encoding = "UTF-8" )
141+         with  gitignore_path .open ("w" , encoding = "UTF-8" ) as  f :
142+             f .write (msg )
140143
141144        cachedir_tag_path  =  self ._cachedir .joinpath ("CACHEDIR.TAG" )
142-         cachedir_tag_path .write_bytes (CACHEDIR_TAG_CONTENT )
145+         with  cachedir_tag_path .open ("wb" ) as  f :
146+             f .write (CACHEDIR_TAG_CONTENT )
143147
144148
145149class  LFPlugin :
@@ -160,7 +164,7 @@ def last_failed_paths(self):
160164        try :
161165            return  self ._last_failed_paths 
162166        except  AttributeError :
163-             rootpath  =  Path (self .config .rootdir )
167+             rootpath  =  Path (str ( self .config .rootdir ) )
164168            result  =  {rootpath  /  nodeid .split ("::" )[0 ] for  nodeid  in  self .lastfailed }
165169            result  =  {x  for  x  in  result  if  x .exists ()}
166170            self ._last_failed_paths  =  result 
@@ -385,7 +389,7 @@ def pytest_report_header(config):
385389        # starting with .., ../.. if sensible 
386390
387391        try :
388-             displaypath  =  cachedir .relative_to (config .rootdir )
392+             displaypath  =  cachedir .relative_to (str ( config .rootdir ) )
389393        except  ValueError :
390394            displaypath  =  cachedir 
391395        return  "cachedir: {}" .format (displaypath )
0 commit comments