Skip to content

Commit 3f466ce

Browse files
committed
Add is_junction method to DirEntry class on Python 3.12
1 parent 39a80cf commit 3f466ce

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pyfakefs/fake_scandir.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,15 @@ def stat(self, follow_symlinks=True):
114114
def __fspath__(self):
115115
return self.path
116116

117+
if sys.version_info >= (3, 12):
118+
def is_junction(self) -> bool:
119+
"""Return True if this entry is a junction.
120+
Junctions are not a part of posix semantic."""
121+
if not self._filesystem.is_windows_fs:
122+
return False
123+
file_object = self._filesystem.resolve(self._abspath)
124+
return file_object.is_junction
125+
117126

118127
class ScanDirIter:
119128
"""Iterator for DirEntry objects returned from `scandir()`

0 commit comments

Comments
 (0)