Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .github/workflows/testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,26 @@ on:
jobs:
tests:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]
experimental: [false]
include:
- python-version: "pypy-3.7"
os: ubuntu-latest
- os: ubuntu-latest
python-version: "pypy-3.7"
experimental: false
- os: ubuntu-latest
python-version: "3.12-dev"
experimental: true
- os: macOS-latest
python-version: "3.12-dev"
experimental: true
- os: windows-latest
python-version: "3.12-dev"
experimental: true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably just disable the tests with extra requirements for 3.12 (by adding a version check to the respective steps). It is common that larger packages do not support a new Python in early development stages. We can remove the check later.


steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -58,14 +70,17 @@ jobs:
fi
shell: bash
- name: Install extra dependencies
if: ${{ ! matrix.experimental }}
run: |
pip install -r extra_requirements.txt
shell: bash
- name: Run unit tests with extra packages as non-root user
if: ${{ ! matrix.experimental }}
run: |
python -m pyfakefs.tests.all_tests
shell: bash
- name: Run performance tests
if: ${{ ! matrix.experimental }}
run: |
if [[ '${{ matrix.os }}' != 'macOS-latest' ]]; then
export TEST_PERFORMANCE=1
Expand Down
13 changes: 13 additions & 0 deletions pyfakefs/fake_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@ def path(self) -> AnyStr:
dir_path = sep.join(names)
return self.filesystem.absnormpath(dir_path)

@property
def is_junction(self) -> bool:
return self.filesystem.isjunction(self.path)

def __getattr__(self, item: str) -> Any:
"""Forward some properties to stat_result."""
if item in self.stat_types:
Expand Down Expand Up @@ -3440,6 +3444,10 @@ def islink(self, path: AnyPath) -> bool:
"""
return self._is_of_type(path, S_IFLNK, follow_symlinks=False)

def isjunction(self, path: AnyPath) -> bool:
"""Junction are never faked."""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: Junction -> Junctions.
You may also add something like "Returns False - junctions are never faked."

return False

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for the time being it is ok to just return False here - I would adapt the description accordingly, though. Later, we may add some convenience function to make a junction in pyfakefs - as far as I can see, this is not possible in Python yet. We also need to adapt os.stat, os.lstat and possibly other functions that will support junctions.


def confirmdir(
self, target_directory: AnyStr, check_owner: bool = False
) -> FakeDirectory:
Expand Down Expand Up @@ -3602,6 +3610,7 @@ def dir() -> List[str]:
"isdir",
"isfile",
"islink",
"isjunction",
"ismount",
"join",
"lexists",
Expand Down Expand Up @@ -3702,6 +3711,10 @@ def islink(self, path: AnyStr) -> bool:
"""
return self.filesystem.islink(path)

def isjunction(self, path: AnyStr) -> bool:
"""Junction are never faked."""
return self.filesystem.isjunction(path)

def getmtime(self, path: AnyStr) -> float:
"""Returns the modification time of the fake file.

Expand Down
5 changes: 5 additions & 0 deletions pyfakefs/fake_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
import fnmatch
import functools
import inspect
import ntpath
import os
import pathlib
import posixpath
import re
import sys
from pathlib import PurePath
Expand Down Expand Up @@ -383,6 +385,7 @@ class _FakeWindowsFlavour(_FakeFlavour):
| {"COM%d" % i for i in range(1, 10)}
| {"LPT%d" % i for i in range(1, 10)}
)
pathmod = ntpath

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class attribute was present but seemingly unused before python/cpython#95450


def is_reserved(self, parts):
"""Return True if the path is considered reserved under Windows."""
Expand Down Expand Up @@ -459,6 +462,8 @@ class _FakePosixFlavour(_FakeFlavour):
independent of FakeFilesystem properties.
"""

pathmod = posixpath

def is_reserved(self, parts):
return False

Expand Down
10 changes: 10 additions & 0 deletions pyfakefs/fake_scandir.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ def stat(self, follow_symlinks=True):
def __fspath__(self):
return self.path

if sys.version_info >= (3, 12):

def is_junction(self) -> bool:
"""Return True if this entry is a junction.
Junctions are not a part of posix semantic."""
if not self._filesystem.is_windows_fs:
return False
file_object = self._filesystem.resolve(self._abspath)
return file_object.is_junction


class ScanDirIter:
"""Iterator for DirEntry objects returned from `scandir()`
Expand Down
1 change: 1 addition & 0 deletions pyfakefs/tests/fake_pathlib_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ def test_symlink_to(self):
self.assertTrue(path.is_symlink())

@unittest.skipIf(sys.version_info < (3, 8), "link_to new in Python 3.8")
@unittest.skipIf(sys.version_info >= (3, 12), "link_to removed in Python 3.12")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this had been deprecated before (actually renamed to hardlink_to).

def test_link_to(self):
self.skip_if_symlink_not_supported()
file_name = self.make_path("foo", "bar.txt")
Expand Down