@@ -60,10 +60,10 @@ class Cache:
60
60
_cachedir = attr .ib (type = Path , repr = False )
61
61
_config = attr .ib (type = Config , repr = False )
62
62
63
- # sub -directory under cache-dir for directories created by "makedir"
63
+ # Sub -directory under cache-dir for directories created by `mkdir()`.
64
64
_CACHE_PREFIX_DIRS = "d"
65
65
66
- # sub -directory under cache-dir for values created by " set"
66
+ # Sub -directory under cache-dir for values created by ` set()`.
67
67
_CACHE_PREFIX_VALUES = "v"
68
68
69
69
def __init__ (
@@ -121,13 +121,15 @@ def warn(self, fmt: str, *, _ispytest: bool = False, **args: object) -> None:
121
121
stacklevel = 3 ,
122
122
)
123
123
124
- def makedir (self , name : str ) -> LEGACY_PATH :
124
+ def mkdir (self , name : str ) -> Path :
125
125
"""Return a directory path object with the given name.
126
126
127
127
If the directory does not yet exist, it will be created. You can use
128
128
it to manage files to e.g. store/retrieve database dumps across test
129
129
sessions.
130
130
131
+ .. versionadded:: 6.3
132
+
131
133
:param name:
132
134
Must be a string not containing a ``/`` separator.
133
135
Make sure the name contains your plugin or application
@@ -138,7 +140,14 @@ def makedir(self, name: str) -> LEGACY_PATH:
138
140
raise ValueError ("name is not allowed to contain path separators" )
139
141
res = self ._cachedir .joinpath (self ._CACHE_PREFIX_DIRS , path )
140
142
res .mkdir (exist_ok = True , parents = True )
141
- return legacy_path (res )
143
+ return res
144
+
145
+ def makedir (self , name : str ) -> LEGACY_PATH :
146
+ """Return a directory path object with the given name.
147
+
148
+ Same as :func:`mkdir`, but returns a legacy py path instance.
149
+ """
150
+ return legacy_path (self .mkdir (name ))
142
151
143
152
def _getvaluepath (self , key : str ) -> Path :
144
153
return self ._cachedir .joinpath (self ._CACHE_PREFIX_VALUES , Path (key ))
@@ -572,8 +581,8 @@ def cacheshow(config: Config, session: Session) -> int:
572
581
contents = sorted (ddir .rglob (glob ))
573
582
tw .sep ("-" , "cache directories for %r" % glob )
574
583
for p in contents :
575
- # if p.check(dir=1 ):
576
- # print("%s/" % p.relto (basedir))
584
+ # if p.is_dir( ):
585
+ # print("%s/" % p.relative_to (basedir))
577
586
if p .is_file ():
578
587
key = str (p .relative_to (basedir ))
579
588
tw .line (f"{ key } is a file of length { p .stat ().st_size :d} " )
0 commit comments