From 4f5ddd5473e2ab80500cda81cc108e83d413be85 Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Thu, 3 Sep 2026 01:43:56 +0530 Subject: [PATCH] test(file-ops): make the unicode-variant retry test filesystem-independent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to the salvaged #95160. The test wrote the NFC spelling of café.txt and read the NFD spelling. APFS resolves NFD lookups to the NFC file directly, so on macOS the compound probe simply found the file, the retry path never ran and r.hint was None -> TypeError (Linux CI passed because ext4 does not alias normalisation forms). Use a curly-vs-ASCII apostrophe instead: still visually identical, still mapped by _unicode_variant_match, and never aliased by any filesystem, so the retry path is exercised everywhere. --- tests/tools/test_file_ops_single_roundtrip.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/tools/test_file_ops_single_roundtrip.py b/tests/tools/test_file_ops_single_roundtrip.py index 1c779682ae..b7d3e95835 100644 --- a/tests/tools/test_file_ops_single_roundtrip.py +++ b/tests/tools/test_file_ops_single_roundtrip.py @@ -11,7 +11,6 @@ import logging import os import sys import threading -import unicodedata from unittest.mock import patch import pytest @@ -160,13 +159,17 @@ class TestReadFileNonTextPaths: def test_unicode_variant_retry_still_works(self, shell, tmp_path): ops, calls = shell - nfc = unicodedata.normalize("NFC", "café.txt") - nfd = unicodedata.normalize("NFD", "café.txt") - assert nfc != nfd - _write(tmp_path, nfc, b"accent\n") - r = ops.read_file(str(tmp_path / nfd)) + # A curly apostrophe vs the ASCII one: visually identical in a + # terminal, and — unlike NFC/NFD — never aliased by the filesystem + # (APFS resolves NFD lookups to NFC files directly, which would skip + # the retry path this test exists to exercise). + on_disk = "it\u2019s.txt" + typed = "it's.txt" + assert on_disk != typed + _write(tmp_path, on_disk, b"accent\n") + r = ops.read_file(str(tmp_path / typed)) assert r.error is None and r.content == "1|accent\n2|" - assert "unicode-equivalent" in r.hint + assert r.hint is not None and "unicode-equivalent" in r.hint def test_directory_is_not_regular(self, shell, tmp_path): ops, calls = shell