Skip to content

Commit

Permalink
use Pathlib instead of path splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
RonnyPfannschmidt committed Jun 22, 2018
1 parent ee30bf4 commit c4c666c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/_pytest/cacheprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@

import pytest
import json
from os.path import sep as _sep, altsep as _altsep
import shutil

from . import paths
from .compat import _PY2 as PY2
from .compat import _PY2 as PY2, Path

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

def _getvaluepath(self, key):
return self._cachedir.joinpath("v", *key.split("/"))
return self._cachedir.joinpath("v", Path(key))

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

0 comments on commit c4c666c

Please sign in to comment.