]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-90473: Skip tests that don't apply to Emscripten and WASI (GH-92846)
authorChristian Heimes <christian@python.org>
Mon, 16 May 2022 14:02:37 +0000 (16:02 +0200)
committerGitHub <noreply@github.com>
Mon, 16 May 2022 14:02:37 +0000 (16:02 +0200)
14 files changed:
Lib/test/support/__init__.py
Lib/test/test__locale.py
Lib/test/test_cmd_line_script.py
Lib/test/test_coroutines.py
Lib/test/test_genericpath.py
Lib/test/test_inspect.py
Lib/test/test_locale.py
Lib/test/test_pydoc.py
Lib/test/test_pyexpat.py
Lib/test/test_re.py
Lib/test/test_robotparser.py
Lib/test/test_selectors.py
Lib/test/test_support.py
Lib/test/test_venv.py

index bddfe118e369d0a3bb6ee6d15f46ddb1b5d0d24a..e4bda940b3dd607ed003406c18b0fa2a1598cf2d 100644 (file)
@@ -521,7 +521,7 @@ def requires_subprocess():
     """Used for subprocess, os.spawn calls, fd inheritance"""
     return unittest.skipUnless(has_subprocess_support, "requires subprocess support")
 
-# Emscripten's socket emulation has limitation. WASI doesn't have sockets yet.
+# Emscripten's socket emulation and WASI sockets have limitations.
 has_socket_support = not is_emscripten and not is_wasi
 
 def requires_working_socket(*, module=False):
index b3bc54cd55104847e3a3ffea171267c93b595154..0947464bb8c04e49ade3f868453cadf32b1e7367 100644 (file)
@@ -109,7 +109,8 @@ class _LocaleTests(unittest.TestCase):
 
     @unittest.skipUnless(nl_langinfo, "nl_langinfo is not available")
     @unittest.skipIf(
-        support.is_emscripten, "musl libc issue on Emscripten, bpo-46390"
+        support.is_emscripten or support.is_wasi,
+        "musl libc issue on Emscripten, bpo-46390"
     )
     def test_lc_numeric_nl_langinfo(self):
         # Test nl_langinfo against known values
@@ -128,7 +129,8 @@ class _LocaleTests(unittest.TestCase):
             self.skipTest('no suitable locales')
 
     @unittest.skipIf(
-        support.is_emscripten, "musl libc issue on Emscripten, bpo-46390"
+        support.is_emscripten or support.is_wasi,
+        "musl libc issue on Emscripten, bpo-46390"
     )
     def test_lc_numeric_localeconv(self):
         # Test localeconv against known values
index bb433dc1e73a435edb9e9254b0d1dc4f4aad338a..d783af65839ad9d2aa8ccb24b9d9487e0b41acab 100644 (file)
@@ -558,8 +558,9 @@ class CmdLineTest(unittest.TestCase):
         # Mac OS X denies the creation of a file with an invalid UTF-8 name.
         # Windows allows creating a name with an arbitrary bytes name, but
         # Python cannot a undecodable bytes argument to a subprocess.
+        # WASI does not permit invalid UTF-8 names.
         if (os_helper.TESTFN_UNDECODABLE
-        and sys.platform not in ('win32', 'darwin')):
+        and sys.platform not in ('win32', 'darwin', 'emscripten', 'wasi')):
             name = os.fsdecode(os_helper.TESTFN_UNDECODABLE)
         elif os_helper.TESTFN_NONASCII:
             name = os_helper.TESTFN_NONASCII
index 77944e678c7504de63ddea1b9430fdf45e23f25f..dba5ceffaf1c03ee37eafc8eec6db4b6510eb999 100644 (file)
@@ -2209,7 +2209,8 @@ class CoroutineTest(unittest.TestCase):
 
 
 @unittest.skipIf(
-    support.is_emscripten, "asyncio does not work under Emscripten yet."
+    support.is_emscripten or support.is_wasi,
+    "asyncio does not work under Emscripten/WASI yet."
 )
 class CoroAsyncIOCompatTest(unittest.TestCase):
 
index 2741adc139bcf6aad69f40ec4adee5585c945bf1..489044f8090d3b7e54bed121553c2dc0537c5219 100644 (file)
@@ -484,7 +484,7 @@ class CommonTest(GenericTest):
         # invalid UTF-8 name. Windows allows creating a directory with an
         # arbitrary bytes name, but fails to enter this directory
         # (when the bytes name is used).
-        and sys.platform not in ('win32', 'darwin', 'emscripten')):
+        and sys.platform not in ('win32', 'darwin', 'emscripten', 'wasi')):
             name = os_helper.TESTFN_UNDECODABLE
         elif os_helper.TESTFN_NONASCII:
             name = os_helper.TESTFN_NONASCII
index fe0259ab609c7f03a75cd583fc8672fc5d46642b..ae1842704d37df1b0b1d83c8d05e288f6b0bf356 100644 (file)
@@ -842,7 +842,10 @@ class TestBuggyCases(GetSourceBase):
         self.assertSourceEqual(mod2.cls213, 218, 222)
         self.assertSourceEqual(mod2.cls213().func219(), 220, 221)
 
-    @unittest.skipIf(support.is_emscripten, "socket.accept is broken")
+    @unittest.skipIf(
+        support.is_emscripten or support.is_wasi,
+        "socket.accept is broken"
+    )
     def test_nested_class_definition_inside_async_function(self):
         import asyncio
         self.addCleanup(asyncio.set_event_loop_policy, None)
index 5cb6edc52d777cfd5eb36d93866fb4976e9b7a89..bc8a7a35fbf2dc4c22d64874d1e5a2bcbbf78542 100644 (file)
@@ -1,5 +1,5 @@
 from decimal import Decimal
-from test.support import verbose, is_android, is_emscripten
+from test.support import verbose, is_android, is_emscripten, is_wasi
 from test.support.warnings_helper import check_warnings
 import unittest
 import locale
@@ -373,13 +373,19 @@ class TestEnUSCollation(BaseLocalizedTest, TestCollation):
 
     @unittest.skipIf(sys.platform.startswith('aix'),
                      'bpo-29972: broken test on AIX')
-    @unittest.skipIf(is_emscripten, "musl libc issue on Emscripten, bpo-46390")
+    @unittest.skipIf(
+        is_emscripten or is_wasi,
+        "musl libc issue on Emscripten/WASI, bpo-46390"
+    )
     def test_strcoll_with_diacritic(self):
         self.assertLess(locale.strcoll('à', 'b'), 0)
 
     @unittest.skipIf(sys.platform.startswith('aix'),
                      'bpo-29972: broken test on AIX')
-    @unittest.skipIf(is_emscripten, "musl libc issue on Emscripten, bpo-46390")
+    @unittest.skipIf(
+        is_emscripten or is_wasi,
+        "musl libc issue on Emscripten/WASI, bpo-46390"
+    )
     def test_strxfrm_with_diacritic(self):
         self.assertLess(locale.strxfrm('à'), locale.strxfrm('b'))
 
index 13c77b6fa6822c8725ca510d5b153e7fd0d6ea9c..ac181effe49bb683927006e1564f87e64d50294c 100644 (file)
@@ -27,7 +27,8 @@ from test.support import os_helper
 from test.support.script_helper import assert_python_ok, assert_python_failure
 from test.support import threading_helper
 from test.support import (reap_children, captured_output, captured_stdout,
-                          captured_stderr, is_emscripten, requires_docstrings)
+                          captured_stderr, is_emscripten, is_wasi,
+                          requires_docstrings)
 from test.support.os_helper import (TESTFN, rmtree, unlink)
 from test import pydoc_mod
 
@@ -1356,7 +1357,10 @@ foo
         )
 
 
-@unittest.skipIf(is_emscripten, "Socket server not available on Emscripten.")
+@unittest.skipIf(
+    is_emscripten or is_wasi,
+    "Socket server not available on Emscripten/WASI."
+)
 class PydocServerTest(unittest.TestCase):
     """Tests for pydoc._start_server"""
 
index 6e578458a25096691dd87e282852a56cdf599897..6f0441b66d9b88c6b1148f274e304bf2a29fd421 100644 (file)
@@ -12,7 +12,7 @@ import traceback
 from xml.parsers import expat
 from xml.parsers.expat import errors
 
-from test.support import sortdict, is_emscripten
+from test.support import sortdict, is_emscripten, is_wasi
 
 
 class SetAttributeTest(unittest.TestCase):
@@ -469,6 +469,7 @@ class HandlerExceptionTest(unittest.TestCase):
             if (sysconfig.is_python_build()
                 and not (sys.platform == 'win32' and platform.machine() == 'ARM')
                 and not is_emscripten
+                and not is_wasi
             ):
                 self.assertIn('call_with_frame("StartElement"', entries[1][3])
 
index ba70de4344bd9d92004f41ab882efe6b0e8b2052..52ee616e210fbbf0068bab8d6283cc13072181ab 100644 (file)
@@ -1,6 +1,6 @@
 from test.support import (gc_collect, bigmemtest, _2G,
                           cpython_only, captured_stdout,
-                          check_disallow_instantiation, is_emscripten)
+                          check_disallow_instantiation, is_emscripten, is_wasi)
 import locale
 import re
 import string
@@ -1943,7 +1943,10 @@ class ReTests(unittest.TestCase):
         # with ignore case.
         self.assertEqual(re.fullmatch('[a-c]+', 'ABC', re.I).span(), (0, 3))
 
-    @unittest.skipIf(is_emscripten, "musl libc issue on Emscripten, bpo-46390")
+    @unittest.skipIf(
+        is_emscripten or is_wasi,
+        "musl libc issue on Emscripten/WASI, bpo-46390"
+    )
     def test_locale_caching(self):
         # Issue #22410
         oldlocale = locale.setlocale(locale.LC_CTYPE)
@@ -1980,7 +1983,10 @@ class ReTests(unittest.TestCase):
         self.assertIsNone(re.match(b'(?Li)\xc5', b'\xe5'))
         self.assertIsNone(re.match(b'(?Li)\xe5', b'\xc5'))
 
-    @unittest.skipIf(is_emscripten, "musl libc issue on Emscripten, bpo-46390")
+    @unittest.skipIf(
+        is_emscripten or is_wasi,
+        "musl libc issue on Emscripten/WASI, bpo-46390"
+    )
     def test_locale_compiled(self):
         oldlocale = locale.setlocale(locale.LC_CTYPE)
         self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale)
index 3821d66c2db7d4b4ac966266db4d2730814311cb..8d89e2a822445254f55bd5889f2754bb9a9b5574 100644 (file)
@@ -308,8 +308,9 @@ class RobotHandler(BaseHTTPRequestHandler):
         pass
 
 
-@unittest.skipIf(
-    support.is_emscripten, "Socket server not available on Emscripten."
+@unittest.skipUnless(
+    support.has_socket_support,
+    "Socket server requires working socket."
 )
 class PasswordProtectedSiteTestCase(unittest.TestCase):
 
index c927331d438b0cb5599def38afb24fd2c677ea30..c2db88c203920a9d2c077fe58ccdc6d040ddaadb 100644 (file)
@@ -19,8 +19,8 @@ except ImportError:
     resource = None
 
 
-if support.is_emscripten:
-    raise unittest.SkipTest("Cannot create socketpair on Emscripten.")
+if support.is_emscripten or support.is_wasi:
+    raise unittest.SkipTest("Cannot create socketpair on Emscripten/WASI.")
 
 
 if hasattr(socket, 'socketpair'):
index dce49809385c676a8e3b2cafee4aaf3d8d135b02..7a8b6819c5a91b37c42544f83094a1d880819f55 100644 (file)
@@ -691,7 +691,7 @@ class TestSupport(unittest.TestCase):
                                  'Warning -- a\nWarning -- b\n')
 
     def test_has_strftime_extensions(self):
-        if support.is_emscripten or support.is_wasi or sys.platform == "win32":
+        if support.is_emscripten or sys.platform == "win32":
             self.assertFalse(support.has_strftime_extensions)
         else:
             self.assertTrue(support.has_strftime_extensions)
index 4f897523907ef4896bb1386f7ef87749a3a77c7c..9f2ecf3be644a51994504b05a233385bd6638ccd 100644 (file)
@@ -16,7 +16,7 @@ import sys
 import tempfile
 from test.support import (captured_stdout, captured_stderr, requires_zlib,
                           skip_if_broken_multiprocessing_synchronize, verbose,
-                          requires_subprocess, is_emscripten,
+                          requires_subprocess, is_emscripten, is_wasi,
                           requires_venv_with_pip)
 from test.support.os_helper import (can_symlink, EnvironmentVarGuard, rmtree)
 import unittest
@@ -35,8 +35,8 @@ requireVenvCreate = unittest.skipUnless(
     or sys._base_executable != sys.executable,
     'cannot run venv.create from within a venv on this platform')
 
-if is_emscripten:
-    raise unittest.SkipTest("venv is not available on Emscripten.")
+if is_emscripten or is_wasi:
+    raise unittest.SkipTest("venv is not available on Emscripten/WASI.")
 
 @requires_subprocess()
 def check_output(cmd, encoding=None):