[svn r38467] make string comparison lowercase-insensitive for windows

--HG--
branch : trunk
This commit is contained in:
hpk 2007-02-11 15:59:56 +01:00
parent 22d98ac3a1
commit c52a54796d
2 changed files with 15 additions and 2 deletions

View File

@ -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. """

View File

@ -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'