From 33fddacee23e0a9e17e417980cdcc211932f689b Mon Sep 17 00:00:00 2001 From: npeter83 Date: Sat, 12 Sep 2026 04:18:35 +0200 Subject: [PATCH] test(plex): the over-long-name guard is asserted the same way on every OS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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.) --- backend/tests/test_plex_subtitle_prepare.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/backend/tests/test_plex_subtitle_prepare.py b/backend/tests/test_plex_subtitle_prepare.py index 53085c17..fcaa4aa0 100644 --- a/backend/tests/test_plex_subtitle_prepare.py +++ b/backend/tests/test_plex_subtitle_prepare.py @@ -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)