Skip to content

Commit 51e6e04

Browse files
committed
Add CI tests for Python 3.14 pre-release
- work around new class checks in pathlib
1 parent 1879dc8 commit 51e6e04

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

.github/workflows/testsuite.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
fail-fast: false
3333
matrix:
3434
os: [ubuntu-latest, macOS-latest, windows-latest]
35-
python-version: [3.8, 3.9, "3.10", "3.11", "3.12", "3.13"]
35+
python-version: [3.8, 3.9, "3.10", "3.11", "3.12", "3.13", "3.14"]
3636
include:
3737
- python-version: "pypy-3.7"
3838
os: ubuntu-22.04
@@ -86,14 +86,14 @@ jobs:
8686
fi
8787
shell: bash
8888
- name: Install extra dependencies
89-
if: ${{ matrix.python-version != 'pypy-3.10' }}
89+
if: ${{ matrix.python-version != '3.14' }}
9090
run: |
9191
pip install -r extra_requirements.txt
9292
pip install -r legacy_requirements.txt
9393
pip install zstandard cffi # needed to test #910
9494
shell: bash
9595
- name: Run unit tests with extra packages as non-root user
96-
if: ${{ matrix.python-version != 'pypy-3.10' }}
96+
if: ${{ matrix.python-version != '3.14' }}
9797
run: |
9898
export PYTHON_ZSTANDARD_IMPORT_POLICY=cffi # needed to test #910
9999
python -m pyfakefs.tests.all_tests

CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ The released versions correspond to PyPI releases.
1212
* the default for `FakeFilesystem.shuffle_listdir_results` will change to `True` to reflect
1313
the real filesystem behavior
1414

15+
## Unreleased
16+
17+
### Changes
18+
* added some preliminary support for Python 3.14
19+
1520
## [Version 5.7.4](https://pypi.python.org/pypi/pyfakefs/5.7.4) (2025-01-14)
1621
Minor bugfix release.
1722

pyfakefs/fake_filesystem_unittest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,11 @@ def setUp(self, doctester: Any = None) -> None:
993993
# do not use the fd functions, as they may not be available in the target OS
994994
if hasattr(shutil, "_use_fd_functions"):
995995
shutil._use_fd_functions = False # type: ignore[module-attr]
996+
# in Python 3.14, _rmtree_impl is set at load time based on _use_fd_functions
997+
# the safe version cannot be used at the moment as it used asserts of type
998+
# 'assert func is os.rmtree', which do not work with the fake versions
999+
if hasattr(shutil, "_rmtree_impl"):
1000+
shutil._rmtree_impl = shutil._rmtree_unsafe # type: ignore[attr-defined]
9961001

9971002
with warnings.catch_warnings():
9981003
# ignore warnings, see #542 and #614

pyfakefs/fake_pathlib.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,19 @@ def group(self):
964964

965965
return grp.getgrgid(self.stat().st_gid).gr_name
966966

967+
if sys.version_info >= (3, 14):
968+
# in Python 3.14, case-sensitivity is checked using an is-check
969+
# (self.parser is posixpath) if not given, which we cannot fake
970+
# therefore we already provide the case sensitivity under Posix
971+
def glob(self, pattern, *, case_sensitive=None, recurse_symlinks=False):
972+
if case_sensitive is None:
973+
case_sensitive = True
974+
return super().glob( # pytype: disable=wrong-keyword-args
975+
pattern,
976+
case_sensitive=case_sensitive,
977+
recurse_symlinks=recurse_symlinks,
978+
)
979+
967980
Path = FakePath
968981

969982
def __getattr__(self, name):

pyfakefs/tests/fake_pathlib_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -996,8 +996,8 @@ def test_glob(self):
996996
sorted(path.glob("*.py")),
997997
)
998998

999-
@unittest.skipIf(not is_windows, "Windows specific test")
1000999
def test_glob_case_windows(self):
1000+
self.check_windows_only()
10011001
self.create_file(self.make_path("foo", "setup.py"))
10021002
self.create_file(self.make_path("foo", "all_tests.PY"))
10031003
self.create_file(self.make_path("foo", "README.md"))
@@ -1012,9 +1012,10 @@ def test_glob_case_windows(self):
10121012
sorted(path.glob("*.py")),
10131013
)
10141014

1015-
@unittest.skipIf(is_windows, "Posix specific test")
10161015
def test_glob_case_posix(self):
10171016
self.check_posix_only()
1017+
if sys.platform == "win32" and sys.version_info < (3, 12):
1018+
self.skipTest(reason="Ignoring inconsistent path delimiters")
10181019
self.create_file(self.make_path("foo", "setup.py"))
10191020
self.create_file(self.make_path("foo", "all_tests.PY"))
10201021
self.create_file(self.make_path("foo", "README.md"))

0 commit comments

Comments
 (0)