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()
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())