Skip to content

Commit

Permalink
Skip tests which interact with invalid UTF-8 files
Browse files Browse the repository at this point in the history
These tests fail on filesystems which disallow
non-UTF8, like ZFS with 'utf8only' on.

Bug: https://bugs.python.org/issue37584
Bug: python#81765
Signed-off-by: Sam James <[email protected]>
  • Loading branch information
thesamesam authored and mgorny committed Aug 1, 2024
1 parent bce7ebb commit 6fe5f87
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions Lib/test/test_cmd_line_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ def test_pep_409_verbiage(self):
self.assertTrue(text[1].startswith(' File '))
self.assertTrue(text[3].startswith('NameError'))

@unittest.skip('Gentoo: fails on ZFS or other strict UTF8-only filesystems (bpo 37584)')
def test_non_ascii(self):
# Apple platforms deny the creation of a file with an invalid UTF-8 name.
# Windows allows creating a name with an arbitrary bytes name, but
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_genericpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ def test_abspath_issue3426(self):
for path in ('', 'fuu', 'f\xf9\xf9', '/fuu', 'U:\\'):
self.assertIsInstance(abspath(path), str)

@unittest.skipIf(os_helper.TESTFN_UNENCODABLE, 'Gentoo: fails on ZFS or other strict UTF8-only filesystems (bpo 37584)')
def test_nonascii_abspath(self):
if (
os_helper.TESTFN_UNDECODABLE
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_httpservers.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ def close_conn():
reader.close()
return body

@unittest.skip('Gentoo: fails on ZFS or other strict UTF8-only filesystems (bpo 37584)')
@unittest.skipIf(is_apple,
'undecodable name cannot always be decoded on Apple platforms')
@unittest.skipIf(sys.platform == 'win32',
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_import/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1816,6 +1816,7 @@ def exec_module(*args):
else:
importlib.SourceLoader.exec_module = old_exec_module

@unittest.skip('Gentoo: fails on ZFS or other strict UTF8-only filesystems (bpo 37584)')
@unittest.skipUnless(TESTFN_UNENCODABLE, 'need TESTFN_UNENCODABLE')
def test_unencodable_filename(self):
# Issue #11619: The Python parser and the import machinery must not
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -2598,6 +2598,7 @@ def add_filename(fn):
def tearDown(self):
shutil.rmtree(self.dir)

@unittest.skipIf(os_helper.TESTFN_UNENCODABLE, 'Gentoo: fails on ZFS or other strict UTF8-only filesystems (bpo 37584)')
def test_listdir(self):
expected = self.unicodefn
found = set(os.listdir(self.dir))
Expand All @@ -2612,11 +2613,13 @@ def test_listdir(self):
finally:
os.chdir(current_directory)

@unittest.skipIf(os_helper.TESTFN_UNENCODABLE, 'Gentoo: fails on ZFS or other strict UTF8-only filesystems (bpo 37584)')
def test_open(self):
for fn in self.unicodefn:
f = open(os.path.join(self.dir, fn), 'rb')
f.close()

@unittest.skipIf(os_helper.TESTFN_UNENCODABLE, 'Gentoo: fails on ZFS or other strict UTF8-only filesystems (bpo 37584)')
@unittest.skipUnless(hasattr(os, 'statvfs'),
"need os.statvfs()")
def test_statvfs(self):
Expand All @@ -2626,6 +2629,7 @@ def test_statvfs(self):
fullname = os.path.join(self.dir, fn)
os.statvfs(fullname)

@unittest.skipIf(os_helper.TESTFN_UNENCODABLE, 'Gentoo: fails on ZFS or other strict UTF8-only filesystems (bpo 37584)')
def test_stat(self):
for fn in self.unicodefn:
os.stat(os.path.join(self.dir, fn))
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_sqlite3/test_dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ def test_open_with_path_like_object(self):
self.assertTrue(os.path.exists(path))
cx.execute(self._sql)

@unittest.skip('Gentoo: fails on ZFS or other strict UTF8-only filesystems (bpo 37584)')
@unittest.skipIf(sys.platform == "win32", "skipped on Windows")
@unittest.skipIf(is_apple, "skipped on Apple platforms")
@unittest.skipIf(is_emscripten or is_wasi, "not supported on Emscripten/WASI")
Expand Down Expand Up @@ -717,6 +718,7 @@ def test_open_uri_readonly(self):
with self.assertRaises(sqlite.OperationalError):
cx.execute(self._sql)

@unittest.skip('Gentoo: fails on ZFS or other strict UTF8-only filesystems (bpo 37584)')
@unittest.skipIf(sys.platform == "win32", "skipped on Windows")
@unittest.skipIf(is_apple, "skipped on Apple platforms")
@unittest.skipIf(is_emscripten or is_wasi, "not supported on Emscripten/WASI")
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_unicode_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,13 @@ def _test_single(self, filename):

# The 'test' functions are unittest entry points, and simply call our
# _test functions with each of the filename combinations we wish to test
@unittest.skipIf(TESTFN_UNENCODABLE, 'Gentoo: fails on ZFS or other strict UTF8-only filesystems (bpo 37584)')
def test_single_files(self):
self._test_single(TESTFN_UNICODE)
if TESTFN_UNENCODABLE is not None:
self._test_single(TESTFN_UNENCODABLE)

@unittest.skipIf(TESTFN_UNENCODABLE, 'Gentoo: fails on ZFS or other strict UTF8-only filesystems (bpo 37584)')
def test_directories(self):
# For all 'equivalent' combinations:
# Make dir with encoded, chdir with unicode, checkdir with encoded
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_unicode_file_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def test_open(self):
os.stat(name)
self._apply_failure(os.listdir, name, self._listdir_failure)

@unittest.skip('Gentoo: fails on ZFS or other strict UTF8-only filesystems (bpo 37584)')
# Skip the test on Apple platforms, because they don't normalize the filename to
# NFD (a variant of Unicode NFD form). Normalize the filename to NFC, NFKC,
# NFKD in Python is useless, because darwin will normalize it later and so
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_zipimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@ def testTraceback(self):
files = {TESTMOD + ".py": raise_src}
self.doTest(None, files, TESTMOD, call=self.doTraceback)

@unittest.skip('Gentoo: fails on ZFS or other strict UTF8-only filesystems (bpo 37584)')
@unittest.skipIf(os_helper.TESTFN_UNENCODABLE is None,
"need an unencodable filename")
def testUnencodable(self):
Expand Down

0 comments on commit 6fe5f87

Please sign in to comment.