diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2020-06-07 14:57:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-07 14:57:45 (GMT) |
commit | 2efe18bf277dd0f38a1d248ae6bdd30947c26880 (patch) | |
tree | ae3a827bca4fe68fa1263e9d11f3dec72223b2fb /Lib/test/test_importlib | |
parent | 47a23fc63fa5df2da8dbc542e78e521d4a7f10c9 (diff) | |
download | cpython-2efe18bf277dd0f38a1d248ae6bdd30947c26880.zip cpython-2efe18bf277dd0f38a1d248ae6bdd30947c26880.tar.gz cpython-2efe18bf277dd0f38a1d248ae6bdd30947c26880.tar.bz2 |
bpo-39791: Support file systems that cannot support non-ascii filenames (skipping tests in that case). (#20681)
Diffstat (limited to 'Lib/test/test_importlib')
-rw-r--r-- | Lib/test/test_importlib/fixtures.py | 11 | ||||
-rw-r--r-- | Lib/test/test_importlib/test_main.py | 9 |
2 files changed, 18 insertions, 2 deletions
diff --git a/Lib/test/test_importlib/fixtures.py b/Lib/test/test_importlib/fixtures.py index b25febb..2e55d14 100644 --- a/Lib/test/test_importlib/fixtures.py +++ b/Lib/test/test_importlib/fixtures.py @@ -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() diff --git a/Lib/test/test_importlib/test_main.py b/Lib/test/test_importlib/test_main.py index 7b18c3d..91e501a 100644 --- a/Lib/test/test_importlib/test_main.py +++ b/Lib/test/test_importlib/test_main.py @@ -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()) |