fix bestrelpath related tests and docstrings
--HG-- branch : 1.0.x
This commit is contained in:
parent
66cf2d3092
commit
67c4503d1b
|
@ -638,7 +638,9 @@ raise ValueError()
|
||||||
repr = excinfo.getrepr(abspath=False)
|
repr = excinfo.getrepr(abspath=False)
|
||||||
repr.toterminal(tw)
|
repr.toterminal(tw)
|
||||||
line = tw.lines[-1]
|
line = tw.lines[-1]
|
||||||
assert line == "mod.py:3: ValueError"
|
x = py.path.local().bestrelpath(path)
|
||||||
|
if len(x) < len(str(path)):
|
||||||
|
assert line == "mod.py:3: ValueError"
|
||||||
|
|
||||||
repr = excinfo.getrepr(abspath=True)
|
repr = excinfo.getrepr(abspath=True)
|
||||||
repr.toterminal(tw)
|
repr.toterminal(tw)
|
||||||
|
|
|
@ -152,14 +152,14 @@ class PathBase(object):
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def bestrelpath(self, dest):
|
def bestrelpath(self, dest):
|
||||||
""" return relative path from self to dest
|
""" return a string which is a relative path from self
|
||||||
such that self.join(bestrelpath) == dest.
|
to dest such that self.join(bestrelpath) == dest and
|
||||||
if not such path can be determined return dest.
|
if not such path can be determined return dest.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
base = self.common(dest)
|
base = self.common(dest)
|
||||||
if not base: # can be the case on windows
|
if not base: # can be the case on windows
|
||||||
return dest
|
return str(dest)
|
||||||
self2base = self.relto(base)
|
self2base = self.relto(base)
|
||||||
reldest = dest.relto(base)
|
reldest = dest.relto(base)
|
||||||
if self2base:
|
if self2base:
|
||||||
|
@ -172,7 +172,7 @@ class PathBase(object):
|
||||||
target = dest.sep.join(l)
|
target = dest.sep.join(l)
|
||||||
return target
|
return target
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return dest
|
return str(dest)
|
||||||
|
|
||||||
|
|
||||||
def parts(self, reverse=False):
|
def parts(self, reverse=False):
|
||||||
|
|
Loading…
Reference in New Issue