Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyfakefs PurePosixPath reports Windows reserved names as reserved on Python3.12+ #1067

Closed
lengau opened this issue Oct 4, 2024 · 0 comments
Labels

Comments

@lengau
Copy link
Contributor

lengau commented Oct 4, 2024

Describe the bug
Windows reserved paths are not reported as reserved in PureWindowsPath with Python 3.12+

How To Reproduce

import pathlib
import pyfakefs
import pytest

WINDOWS_RESERVED_NAMES = (
    "CON", "PRN", "AUX", "NUL",
    "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
    "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9",
)


@pytest.mark.parametrize(
    "reserved_name", WINDOWS_RESERVED_NAMES
)
def test_real_fs_com1(reserved_name):
    assert not pathlib.PurePosixPath(reserved_name).is_reserved()
    assert not pathlib.PurePosixPath(reserved_name + ".txt").is_reserved()


@pytest.mark.parametrize(
    "reserved_name", WINDOWS_RESERVED_NAMES
)
def test_fake_fs_com1(fs, reserved_name):
    assert not pathlib.PurePosixPath(reserved_name).is_reserved()
    assert not pathlib.PurePosixPath(reserved_name + ".txt").is_reserved()

Your environment

Linux-6.11.0-8-generic-x86_64-with-glibc2.40
Python 3.11.10 (main, Sep  9 2024, 22:11:19) [Clang 18.1.8 ]
pyfakefs 5.7.dev0
pytest 8.3.3
mrbean-bremen added a commit to lengau/pyfakefs that referenced this issue Oct 7, 2024
- had been only patched for pathlib.Path
- avoid possible recursion in PurePath.joinpath
- fixes pytest-dev#1067
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants