Commits

holger krekel committed dac3d52

fix issue #20 path.samefile(relpath) works

  • Participants
  • Parent commits bae37c2

Comments (0)

Files changed (5)

 
 - fix py.error.* attribute pypy access issue
 
+- allow path.samefile(arg) to succeed when arg is a relative filename
+
+- fix (pytest-) issue20 path.samefile(relpath) works as expected now
+
 Changes between 1.3.4 and 1.4.0
 ==================================================
 

File py/__init__.py

 
 (c) Holger Krekel and others, 2004-2010
 """
-__version__ = '1.4.1.dev3'
+__version__ = '1.4.1.dev4'
 
 from py import _apipkg
 

File py/_path/local.py

 
     def samefile(self, other):
         """ return True if 'other' references the same file as 'self'. """
-        if self == other:
-            return True
         if not iswin32:
-            return py.error.checked_call(os.path.samefile, str(self), str(other))
-        return False
+            return py.error.checked_call(
+                    os.path.samefile, str(self), str(other))
+        if not os.path.isabs(other):
+            other = os.path.abspath(other)
+        return self == other
 
     def remove(self, rec=1, ignore_errors=False):
         """ remove a file or directory (or a directory tree if rec=1).
         name='py',
         description='library with cross-python path, ini-parsing, io, code, log facilities',
         long_description = open('README.txt').read(),
-        version='1.4.1.dev3',
+        version='1.4.1.dev4',
         url='http://pylib.org',
         license='MIT license',
         platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],

File testing/path/test_local.py

     assert tmpdir.samefile(tmpdir)
     p = tmpdir.ensure("hello")
     assert p.samefile(p)
+    old = p.dirpath().chdir()
+    try:
+        assert p.samefile(p.basename)
+    finally:
+        old.chdir()
     if sys.platform == "win32":
         p1 = p.__class__(str(p).lower())
         p2 = p.__class__(str(p).upper())