Skip to content

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

@lengau

Description

@lengau

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions