]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-39791: Support file systems that cannot support non-ascii filenames (skipping...
authorJason R. Coombs <jaraco@jaraco.com>
Sun, 7 Jun 2020 14:57:45 +0000 (10:57 -0400)
committerGitHub <noreply@github.com>
Sun, 7 Jun 2020 14:57:45 +0000 (10:57 -0400)
Lib/test/test_importlib/fixtures.py
Lib/test/test_importlib/test_main.py

index b25febb7fe756417a9bf5a53d63fd48057c708ad..2e55d14b9aab9713147497c7de32a58e3c663577 100644 (file)
@@ -210,6 +210,17 @@ def build_files(file_defs, prefix=pathlib.Path()):
                     f.write(DALS(contents))
 
 
+class FileBuilder:
+    def unicode_filename(self):
+        try:
+            import test.support
+        except ImportError:
+            # outside CPython, hard-code a unicode snowman
+            return '☃'
+        return test.support.FS_NONASCII or \
+            self.skip("File system does not support non-ascii.")
+
+
 def DALS(str):
     "Dedent and left-strip"
     return textwrap.dedent(str).lstrip()
index 7b18c3de16eea083a595a621ca3e5d6f2ca96784..91e501a2eb7cdc4889ca9a67a073086e57bbfb75 100644 (file)
@@ -254,11 +254,16 @@ class TestEntryPoints(unittest.TestCase):
         assert self.ep.attr is None
 
 
-class FileSystem(fixtures.OnSysPath, fixtures.SiteDir, unittest.TestCase):
+class FileSystem(
+        fixtures.OnSysPath, fixtures.SiteDir, fixtures.FileBuilder,
+        unittest.TestCase):
     def test_unicode_dir_on_sys_path(self):
         """
         Ensure a Unicode subdirectory of a directory on sys.path
         does not crash.
         """
-        fixtures.build_files({'☃': {}}, prefix=self.site_dir)
+        fixtures.build_files(
+            {self.unicode_filename(): {}},
+            prefix=self.site_dir,
+            )
         list(distributions())