remove other py.* accesses in _pytest._py.path
This commit is contained in:
parent
965e942dfb
commit
a7c1fc204b
|
@ -428,9 +428,9 @@ class PathBase:
|
||||||
|
|
||||||
class Visitor:
|
class Visitor:
|
||||||
def __init__(self, fil, rec, ignore, bf, sort):
|
def __init__(self, fil, rec, ignore, bf, sort):
|
||||||
if isinstance(fil, py.builtin._basestring):
|
if isinstance(fil, str):
|
||||||
fil = FNMatcher(fil)
|
fil = FNMatcher(fil)
|
||||||
if isinstance(rec, py.builtin._basestring):
|
if isinstance(rec, str):
|
||||||
self.rec = FNMatcher(rec)
|
self.rec = FNMatcher(rec)
|
||||||
elif not hasattr(rec, "__call__") and rec:
|
elif not hasattr(rec, "__call__") and rec:
|
||||||
self.rec = lambda path: True
|
self.rec = lambda path: True
|
||||||
|
@ -882,7 +882,7 @@ class LocalPath(FSBase):
|
||||||
if fil is None and sort is None:
|
if fil is None and sort is None:
|
||||||
names = error.checked_call(os.listdir, self.strpath)
|
names = error.checked_call(os.listdir, self.strpath)
|
||||||
return map_as_list(self._fastjoin, names)
|
return map_as_list(self._fastjoin, names)
|
||||||
if isinstance(fil, py.builtin._basestring):
|
if isinstance(fil, str):
|
||||||
if not self._patternchars.intersection(fil):
|
if not self._patternchars.intersection(fil):
|
||||||
child = self._fastjoin(fil)
|
child = self._fastjoin(fil)
|
||||||
if exists(child.strpath):
|
if exists(child.strpath):
|
||||||
|
@ -989,14 +989,14 @@ class LocalPath(FSBase):
|
||||||
if ensure:
|
if ensure:
|
||||||
self.dirpath().ensure(dir=1)
|
self.dirpath().ensure(dir=1)
|
||||||
if "b" in mode:
|
if "b" in mode:
|
||||||
if not py.builtin._isbytes(data):
|
if not isinstance(data, bytes):
|
||||||
raise ValueError("can only process bytes")
|
raise ValueError("can only process bytes")
|
||||||
else:
|
else:
|
||||||
if not py.builtin._istext(data):
|
if not isinstance(data, str):
|
||||||
if not py.builtin._isbytes(data):
|
if not isinstance(data, bytes):
|
||||||
data = str(data)
|
data = str(data)
|
||||||
else:
|
else:
|
||||||
data = py.builtin._totext(data, sys.getdefaultencoding())
|
data = data.decode(sys.getdefaultencoding())
|
||||||
f = self.open(mode)
|
f = self.open(mode)
|
||||||
try:
|
try:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
@ -1221,7 +1221,8 @@ class LocalPath(FSBase):
|
||||||
mod.__file__ = str(self)
|
mod.__file__ = str(self)
|
||||||
sys.modules[modname] = mod
|
sys.modules[modname] = mod
|
||||||
try:
|
try:
|
||||||
py.builtin.execfile(str(self), mod.__dict__)
|
with open(str(self), "rb") as f:
|
||||||
|
exec(f.read(), mod.__dict__)
|
||||||
except:
|
except:
|
||||||
del sys.modules[modname]
|
del sys.modules[modname]
|
||||||
raise
|
raise
|
||||||
|
@ -1239,12 +1240,12 @@ class LocalPath(FSBase):
|
||||||
proc = Popen([str(self)] + argv, **popen_opts)
|
proc = Popen([str(self)] + argv, **popen_opts)
|
||||||
stdout, stderr = proc.communicate()
|
stdout, stderr = proc.communicate()
|
||||||
ret = proc.wait()
|
ret = proc.wait()
|
||||||
if py.builtin._isbytes(stdout):
|
if isinstance(stdout, bytes):
|
||||||
stdout = py.builtin._totext(stdout, sys.getdefaultencoding())
|
stdout = stdout.decode(sys.getdefaultencoding())
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
if py.builtin._isbytes(stderr):
|
if isinstance(stderr, bytes):
|
||||||
stderr = py.builtin._totext(stderr, sys.getdefaultencoding())
|
stderr = stderr.decode(sys.getdefaultencoding())
|
||||||
raise py.process.cmdexec.Error(
|
raise RuntimeError(
|
||||||
ret,
|
ret,
|
||||||
ret,
|
ret,
|
||||||
str(self),
|
str(self),
|
||||||
|
@ -1262,7 +1263,7 @@ class LocalPath(FSBase):
|
||||||
but may work on cygwin.
|
but may work on cygwin.
|
||||||
"""
|
"""
|
||||||
if isabs(name):
|
if isabs(name):
|
||||||
p = py.path.local(name)
|
p = local(name)
|
||||||
if p.check(file=1):
|
if p.check(file=1):
|
||||||
return p
|
return p
|
||||||
else:
|
else:
|
||||||
|
@ -1288,7 +1289,7 @@ class LocalPath(FSBase):
|
||||||
|
|
||||||
for x in paths:
|
for x in paths:
|
||||||
for addext in tryadd:
|
for addext in tryadd:
|
||||||
p = py.path.local(x).join(name, abs=True) + addext
|
p = local(x).join(name, abs=True) + addext
|
||||||
try:
|
try:
|
||||||
if p.check(file=1):
|
if p.check(file=1):
|
||||||
if checker:
|
if checker:
|
||||||
|
@ -1323,7 +1324,7 @@ class LocalPath(FSBase):
|
||||||
"""
|
"""
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
return py.path.local(tempfile.gettempdir())
|
return local(tempfile.gettempdir())
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def mkdtemp(cls, rootdir=None):
|
def mkdtemp(cls, rootdir=None):
|
||||||
|
|
Loading…
Reference in New Issue