Skip to content

Commit 71f5016

Browse files
bpo-39791: Support file systems that cannot support non-ascii filenames (skipping tests in that case). (GH-20681)
(cherry picked from commit 2efe18b) Co-authored-by: Jason R. Coombs <[email protected]>
1 parent 1d711f2 commit 71f5016

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

Lib/test/test_importlib/fixtures.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,17 @@ def build_files(file_defs, prefix=pathlib.Path()):
210210
f.write(DALS(contents))
211211

212212

213+
class FileBuilder:
214+
def unicode_filename(self):
215+
try:
216+
import test.support
217+
except ImportError:
218+
# outside CPython, hard-code a unicode snowman
219+
return '☃'
220+
return test.support.FS_NONASCII or \
221+
self.skip("File system does not support non-ascii.")
222+
223+
213224
def DALS(str):
214225
"Dedent and left-strip"
215226
return textwrap.dedent(str).lstrip()

Lib/test/test_importlib/test_main.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,16 @@ def test_attr(self):
254254
assert self.ep.attr is None
255255

256256

257-
class FileSystem(fixtures.OnSysPath, fixtures.SiteDir, unittest.TestCase):
257+
class FileSystem(
258+
fixtures.OnSysPath, fixtures.SiteDir, fixtures.FileBuilder,
259+
unittest.TestCase):
258260
def test_unicode_dir_on_sys_path(self):
259261
"""
260262
Ensure a Unicode subdirectory of a directory on sys.path
261263
does not crash.
262264
"""
263-
fixtures.build_files({'☃': {}}, prefix=self.site_dir)
265+
fixtures.build_files(
266+
{self.unicode_filename(): {}},
267+
prefix=self.site_dir,
268+
)
264269
list(distributions())

0 commit comments

Comments
 (0)