diff --git a/tests/__init__.py b/tests/__init__.py index c7c7e47..70e7c21 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,3 +1,4 @@ +import platform import sys import zipfile from pathlib import Path @@ -117,6 +118,22 @@ def uncommon_text() -> str: return "\033[31;1;4m BaD TeΧt \u200d ❌ \033[0m" +@pytest.fixture +def uncommon_filename(uncommon_text: str) -> str: + """Craft a filename with Unicode characters that are considered not common. + + We reuse the same uncommon string as above, with a small exception for macOS. + Because the APFS filesystem in macOS accepts only UTF-8 encoded strings [1], we + cannot create a filename with invalid Unicode characters. So, in order to test the + rest of the corner cases, we replace U+DCF0 with an empty string. + + [1]: https://en.wikipedia.org/wiki/Filename#Comparison_of_filename_limitations + """ + if platform.system() == "Darwin": + uncommon_text = uncommon_text.replace("\udcf0", "") + return uncommon_text + ".pdf" + + @pytest.fixture def sanitized_text() -> str: """Return a sanitized version of the uncommon_text."""