From 37a41ed0b72010c8bf74bca2a0170dcf666d9f95 Mon Sep 17 00:00:00 2001 From: hpk Date: Thu, 21 Aug 2008 12:00:33 +0200 Subject: [PATCH] [svn r57536] get the py.path fixes of 0.9.x release branch back to trunk --HG-- branch : trunk --- py/path/common.py | 6 +++++- py/path/gateway/channeltest.py | 4 ++-- py/path/gateway/channeltest2.py | 5 ++--- py/path/gateway/remotepath.py | 2 +- py/path/local/local.py | 4 ---- py/path/local/testing/test_local.py | 5 +++++ py/path/local/testing/test_win.py | 5 +++++ 7 files changed, 20 insertions(+), 11 deletions(-) diff --git a/py/path/common.py b/py/path/common.py index d0723d479..b747d6135 100644 --- a/py/path/common.py +++ b/py/path/common.py @@ -142,7 +142,11 @@ class PathBase(object): #assert strrelpath[-1] == self.sep #assert strrelpath[-2] != self.sep strself = str(self) - if strself.startswith(strrelpath): + if sys.platform == "win32": + if os.path.normcase(strself).startswith( + os.path.normcase(strrelpath)): + return strself[len(strrelpath):] + elif strself.startswith(strrelpath): return strself[len(strrelpath):] return "" diff --git a/py/path/gateway/channeltest.py b/py/path/gateway/channeltest.py index 9d77ef01f..fdb46ab9b 100644 --- a/py/path/gateway/channeltest.py +++ b/py/path/gateway/channeltest.py @@ -25,7 +25,7 @@ class PathServer: def command_GET(self, id, spec): path = self.C2P[id] - self.channel.send(path._getbyspec(spec)) + self.channel.send(path.get(spec)) def command_READ(self, id): path = self.C2P[id] @@ -53,7 +53,7 @@ class PathServer: if __name__ == '__main__': import py gw = py.execnet.PopenGateway() - channel = gw._channelfactory.new() + channel = gw.channelfactory.new() srv = PathServer(channel) c = gw.remote_exec(""" import remotepath diff --git a/py/path/gateway/channeltest2.py b/py/path/gateway/channeltest2.py index f15ac94d1..f22026d04 100644 --- a/py/path/gateway/channeltest2.py +++ b/py/path/gateway/channeltest2.py @@ -13,9 +13,8 @@ channel.send(srv.p2c(py.path.local("/tmp"))) #gw = py.execnet.SshGateway('codespeak.net') gw = py.execnet.PopenGateway() -gw.remote_init_threads(5) -c = gw.remote_exec(SRC, stdout=py.std.sys.stdout, stderr=py.std.sys.stderr) -subchannel = gw._channelfactory.new() +c = gw.remote_exec(SRC) +subchannel = gw.channelfactory.new() c.send(subchannel) p = RemotePath(subchannel, c.receive()) diff --git a/py/path/gateway/remotepath.py b/py/path/gateway/remotepath.py index a8d8d8529..5f5e538be 100644 --- a/py/path/gateway/remotepath.py +++ b/py/path/gateway/remotepath.py @@ -33,7 +33,7 @@ class RemotePath(common.FSPathBase): self._channel.send(('JOIN', self._id, id) + args) return RemotePath(self._channel, id) - def _getbyspec(self, spec): + def get(self, spec): parts = spec.split(',') ask = [x for x in parts if x not in self._specs] if ask: diff --git a/py/path/local/local.py b/py/path/local/local.py index 06b8b0deb..eff910a5a 100644 --- a/py/path/local/local.py +++ b/py/path/local/local.py @@ -390,10 +390,6 @@ class LocalPath(common.FSPathBase, PlatformMixin): #print "trying to import", self pkgpath = None if modname is None: - #try: - # return self._module - #except AttributeError: - # pass pkgpath = self.pypkgpath() if pkgpath is not None: if ensuresyspath: diff --git a/py/path/local/testing/test_local.py b/py/path/local/testing/test_local.py index 93b457489..9aeb09492 100644 --- a/py/path/local/testing/test_local.py +++ b/py/path/local/testing/test_local.py @@ -1,4 +1,5 @@ import py +import sys from py.path import local from py.__.path.common import checker from py.__.path.testing.fscommon import CommonFSTests, setuptestfs @@ -178,6 +179,10 @@ class TestLocalPath(LocalSetup, CommonFSTests): assert not hasattr(l3, 'commit') def test_long_filenames(self): + if sys.platform == "win32": + py.test.skip("win32: work around needed for path length limit") + # see http://codespeak.net/pipermail/py-dev/2008q2/000922.html + tmpdir = self.tmpdir # testing paths > 260 chars (which is Windows' limitation, but # depending on how the paths are used), but > 4096 (which is the diff --git a/py/path/local/testing/test_win.py b/py/path/local/testing/test_win.py index 1f10b7a71..12d6377b6 100644 --- a/py/path/local/testing/test_win.py +++ b/py/path/local/testing/test_win.py @@ -29,6 +29,11 @@ class TestWINLocalPath: t2 = self.root.join("A_path") assert t1 == t1 assert t1 == t2 + + def test_relto_with_mixed_case(self): + t1 = self.root.join("a_path", "fiLe") + t2 = self.root.join("A_path") + assert t1.relto(t2) == "fiLe" def test_allow_unix_style_paths(self): t1 = self.root.join('a_path')