holger krekel committed dac3d52

fix issue #20 path.samefile(relpath) works

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
 (c) Holger Krekel and others, 2004-2010
-__version__ = '1.4.1.dev3'
+__version__ = '1.4.1.dev4'
 from py import _apipkg


     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).
         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',
         license='MIT license',
         platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],


     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())
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.