From c52a54796dd583b4de0919306df442f240f16f5d Mon Sep 17 00:00:00 2001 From: hpk Date: Sun, 11 Feb 2007 15:59:56 +0100 Subject: [PATCH] [svn r38467] make string comparison lowercase-insensitive for windows --HG-- branch : trunk --- py/path/local/local.py | 11 +++++++++-- py/path/local/testing/test_win.py | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/py/path/local/local.py b/py/path/local/local.py index 853d194a5..cfc96c722 100644 --- a/py/path/local/local.py +++ b/py/path/local/local.py @@ -10,7 +10,9 @@ import sys, os, stat, re, atexit import py from py.__.path import common -if sys.platform == 'win32': +iswin32 = sys.platform == "win32" + +if iswin32: from py.__.path.local.win import WinMixin as PlatformMixin else: from py.__.path.local.posix import PosixMixin as PlatformMixin @@ -193,7 +195,12 @@ class LocalPath(common.FSPathBase, PlatformMixin): return obj def __eq__(self, other): - return str(self) == str(other) + s1 = str(self) + s2 = str(other) + if iswin32: + s1 = s1.lower() + s2 = s2.lower() + return s1 == s2 def open(self, mode='r'): """ return an opened file with the given mode. """ diff --git a/py/path/local/testing/test_win.py b/py/path/local/testing/test_win.py index 77209427b..1f10b7a71 100644 --- a/py/path/local/testing/test_win.py +++ b/py/path/local/testing/test_win.py @@ -24,6 +24,12 @@ class TestWINLocalPath: self.root.chmod(mode) assert self.root.stat().st_mode == mode + def test_path_comparison_lowercase_mixed(self): + t1 = self.root.join("a_path") + t2 = self.root.join("A_path") + assert t1 == t1 + assert t1 == t2 + def test_allow_unix_style_paths(self): t1 = self.root.join('a_path') assert t1 == str(self.root) + '\\a_path'