Skip to content

Commit c4c666c

Browse files
use Pathlib instead of path splitting
1 parent ee30bf4 commit c4c666c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/_pytest/cacheprovider.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313

1414
import pytest
1515
import json
16-
from os.path import sep as _sep, altsep as _altsep
1716
import shutil
1817

1918
from . import paths
20-
from .compat import _PY2 as PY2
19+
from .compat import _PY2 as PY2, Path
2120

2221
README_CONTENT = u"""\
2322
# pytest cache directory #
@@ -62,14 +61,15 @@ def makedir(self, name):
6261
Make sure the name contains your plugin or application
6362
identifiers to prevent clashes with other cache users.
6463
"""
65-
if _sep in name or _altsep is not None and _altsep in name:
64+
name = Path(name)
65+
if len(name.parts) > 1:
6666
raise ValueError("name is not allowed to contain path separators")
6767
res = self._cachedir.joinpath("d", name)
6868
res.mkdir(exist_ok=True, parents=True)
6969
return py.path.local(res)
7070

7171
def _getvaluepath(self, key):
72-
return self._cachedir.joinpath("v", *key.split("/"))
72+
return self._cachedir.joinpath("v", Path(key))
7373

7474
def get(self, key, default):
7575
""" return cached value for the given key. If no value

0 commit comments

Comments
 (0)