File tree 3 files changed +16
-3
lines changed
3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 1
1
Unreleased
2
2
==========
3
3
4
- - handle ``FileNotFoundError`` when trying to import pathlib in ``path.common``
4
+ - Handle ``FileNotFoundError`` when trying to import pathlib in ``path.common``
5
5
on Python 3.4 (#207).
6
6
7
+ - ``py.path.local.samefile`` now works correctly in Python 3 on Windows when dealing with symlinks.
8
+
7
9
1.8.0 (2019-02-21)
8
10
==================
9
11
Original file line number Diff line number Diff line change @@ -196,8 +196,8 @@ def samefile(self, other):
196
196
other = abspath (other )
197
197
if self == other :
198
198
return True
199
- if iswin32 :
200
- return False # there is no samefile
199
+ if not hasattr ( os . path , "samefile" ) :
200
+ return False
201
201
return py .error .checked_call (
202
202
os .path .samefile , self .strpath , other )
203
203
Original file line number Diff line number Diff line change @@ -704,6 +704,17 @@ def test_samefile(tmpdir):
704
704
p2 = p .__class__ (str (p ).upper ())
705
705
assert p1 .samefile (p2 )
706
706
707
+ @pytest .mark .skipif (not hasattr (os , "symlink" ), reason = "os.symlink not available" )
708
+ def test_samefile_symlink (tmpdir ):
709
+ p1 = tmpdir .ensure ("foo.txt" )
710
+ p2 = tmpdir .join ("linked.txt" )
711
+ try :
712
+ os .symlink (str (p1 ), str (p2 ))
713
+ except OSError as e :
714
+ # on Windows this might fail if the user doesn't have special symlink permissions
715
+ pytest .skip (str (e .args [0 ]))
716
+
717
+ assert p1 .samefile (p2 )
707
718
708
719
def test_listdir_single_arg (tmpdir ):
709
720
tmpdir .ensure ("hello" )
You can’t perform that action at this time.
0 commit comments