From 67c4503d1bc3fc707ecae8459d134fccf36d4dd4 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Tue, 4 Aug 2009 09:32:05 +0200 Subject: [PATCH] fix bestrelpath related tests and docstrings --HG-- branch : 1.0.x --- py/code/testing/test_excinfo.py | 4 +++- py/path/common.py | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/py/code/testing/test_excinfo.py b/py/code/testing/test_excinfo.py index e53e3eb90..2d1b43661 100644 --- a/py/code/testing/test_excinfo.py +++ b/py/code/testing/test_excinfo.py @@ -638,7 +638,9 @@ raise ValueError() repr = excinfo.getrepr(abspath=False) repr.toterminal(tw) 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.toterminal(tw) diff --git a/py/path/common.py b/py/path/common.py index ec5d45386..3a46ce8d9 100644 --- a/py/path/common.py +++ b/py/path/common.py @@ -152,14 +152,14 @@ class PathBase(object): return "" def bestrelpath(self, dest): - """ return relative path from self to dest - such that self.join(bestrelpath) == dest. + """ return a string which is a relative path from self + to dest such that self.join(bestrelpath) == dest and if not such path can be determined return dest. """ try: base = self.common(dest) if not base: # can be the case on windows - return dest + return str(dest) self2base = self.relto(base) reldest = dest.relto(base) if self2base: @@ -172,7 +172,7 @@ class PathBase(object): target = dest.sep.join(l) return target except AttributeError: - return dest + return str(dest) def parts(self, reverse=False):