@@ -34,10 +34,14 @@ def make_test_filename(fname, purpose):
3434 return '%s-%s%s' % (base , purpose , ext )
3535
3636
37- def get_cache_dir ():
37+ def _get_cache_path ():
3838 cache_dir = Path (mpl .get_cachedir (), 'test_cache' )
3939 cache_dir .mkdir (parents = True , exist_ok = True )
40- return str (cache_dir )
40+ return cache_dir
41+
42+
43+ def get_cache_dir ():
44+ return str (_get_cache_path ())
4145
4246
4347def get_file_hash (path , block_size = 2 ** 20 ):
@@ -286,7 +290,7 @@ def convert(filename, cache):
286290 # Only convert the file if the destination doesn't already exist or
287291 # is out of date.
288292 if not newpath .exists () or newpath .stat ().st_mtime < path .stat ().st_mtime :
289- cache_dir = Path ( get_cache_dir () ) if cache else None
293+ cache_dir = _get_cache_path ( ) if cache else None
290294
291295 if cache_dir is not None :
292296 _register_conversion_cache_cleaner_once ()
@@ -318,7 +322,7 @@ def _clean_conversion_cache():
318322 max_cache_size = 2 * baseline_images_size
319323 # Reduce cache until it fits.
320324 cache_stat = {
321- path : path .stat () for path in Path ( get_cache_dir () ).glob ("*" )}
325+ path : path .stat () for path in _get_cache_path ( ).glob ("*" )}
322326 cache_size = sum (stat .st_size for stat in cache_stat .values ())
323327 paths_by_atime = sorted ( # Oldest at the end.
324328 cache_stat , key = lambda path : cache_stat [path ].st_atime , reverse = True )
0 commit comments