test(plex): the over-long-name guard is asserted the same way on every OS

Deep-review round 5. The assertion behind `subtitles._exists` was only red where pathlib re-raises
ENAMETOOLONG: on Linux it does, on Windows the same stat fails with ERROR_INVALID_NAME, which
pathlib's `exists()` already swallows — so the assertion passed with the fix reverted. It forces the
errno now instead of relying on the filesystem. (The gate's pytest lane is the Linux container, so
the branch was never actually unguarded; the test was just dishonest about why it passed.)
This commit is contained in:
2026-09-12 04:18:35 +02:00
parent 12121255dd
commit 33fddacee2
+12 -1
View File
@@ -22,6 +22,7 @@ conftest refuses to run without ffmpeg rather than let it skip.
"""
import asyncio
import errno
import shutil
import subprocess
import sys
@@ -1059,7 +1060,17 @@ def test_an_absurd_rating_key_or_ordinal_is_refused_not_a_500(client, monkeypatc
):
assert client.get(url).status_code == 422, url
assert pool.jobs == []
# …and the cache helpers themselves no longer throw on such a name.
# …and the cache helpers themselves no longer throw on such a name. Asserted against a forced
# ENAMETOOLONG rather than the real filesystem: on Linux pathlib re-raises it (the defect), but
# Windows reports ERROR_INVALID_NAME, which pathlib's `exists()` already swallows — so on a dev
# machine this assertion passed with `_exists` reverted and only the container lane was honest
# about it (deep-review round 5).
def _too_long(self):
raise OSError(errno.ENAMETOOLONG, "File name too long")
monkeypatch.setattr(Path, "exists", _too_long)
assert subtitles._exists(Path("whatever")) is False
assert subtitles.read_meta(subtitles.cache_key(long_key, 0)) == ([], False)