exdir
exdir copied to clipboard
Python 3.13: test_assert_valid_name_minimal fails due to changed behavior of PurePath.is_reserved()
According to upstream's documentation the behavior of PurePath.is_reserved() has changed in Python 3.13:
Changed in version 3.13: Windows path names that contain a colon, or end with a dot or a space, are considered reserved. UNC paths may be reserved.
Besides the change in behavior, the is_reserved() method is deprecated as of Python 3.13 and will be removed in Python 3.15:
Deprecated since version 3.13, will be removed in version 3.15: This method is deprecated; use os.path.isreserved() to detect reserved paths on Windows.
The change in behavior leads to test_assert_valid_name_minimal failing when asserting validity of path "\n":
=================================== FAILURES ===================================
________________________ test_assert_valid_name_minimal ________________________
setup_teardown_folder = (PosixPath('/tmp/pytest-of-mockbuild/pytest-0/test_assert_valid_name_minimal0'), PosixPath('/tmp/pytest-of-mockbuild/p...d_name_minimal0/test.exdir'), PosixPath('/tmp/pytest-of-mockbuild/pytest-0/test_assert_valid_name_minimal0/exdir_dir'))
def test_assert_valid_name_minimal(setup_teardown_folder):
f = exdir.File(setup_teardown_folder[1], name_validation=fv.minimal)
exob._assert_valid_name("abcdefghijklmnopqrstuvwxyz1234567890_-", f)
with pytest.raises(NameError):
exob._assert_valid_name("", f)
exob._assert_valid_name("A", f)
> exob._assert_valid_name("\n", f)
tests/test_help_functions.py:36:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../BUILDROOT/python-exdir-0.5.0.1-5.fc41.x86_64/usr/lib/python3.13/site-packages/exdir/core/exdir_object.py:22: in _assert_valid_name
container.file.name_validation(container.directory, name)
../../BUILDROOT/python-exdir-0.5.0.1-5.fc41.x86_64/usr/lib/python3.13/site-packages/exdir/core/validation.py:86: in minimal
_assert_nonreserved(name)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
name = '\n'
def _assert_nonreserved(name):
# NOTE ignore unicode errors, they are not reserved
try:
name_str = str(name)
except UnicodeEncodeError:
name_str = name.encode('utf8')
reserved_names = [
exob.META_FILENAME,
exob.ATTRIBUTES_FILENAME,
exob.RAW_FOLDER_NAME
]
if name_str in reserved_names:
raise NameError(
"Name cannot be '{}' because it is a reserved filename in Exdir.".format(name_str)
)
if pathlib.PureWindowsPath(name_str).is_reserved():
> raise NameError(
"Name cannot be '{}' because it is a reserved filename in Windows.".format(name_str)
)
E NameError: Name cannot be '
E ' because it is a reserved filename in Windows.
../../BUILDROOT/python-exdir-0.5.0.1-5.fc41.x86_64/usr/lib/python3.13/site-packages/exdir/core/validation.py:62: NameError