Skip to content

gh-90473: Skip tests that don't apply to Emscripten and WASI #92846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 4 additions & 2 deletions Lib/test/test__locale.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ def numeric_tester(self, calc_type, calc_value, data_type, used_locale):

@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
Expand All @@ -128,7 +129,8 @@ def test_lc_numeric_nl_langinfo(self):
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
Expand Down
3 changes: 2 additions & 1 deletion Lib/test/test_cmd_line_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,9 @@ def test_non_ascii(self):
# 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
Expand Down
3 changes: 2 additions & 1 deletion Lib/test/test_coroutines.py
Original file line number Diff line number Diff line change
Expand Up @@ -2209,7 +2209,8 @@ async def f():


@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):

Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_genericpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def test_nonascii_abspath(self):
# 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
Expand Down
5 changes: 4 additions & 1 deletion Lib/test/test_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,10 @@ def test_nested_class_definition_inside_function(self):
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)
Expand Down
12 changes: 9 additions & 3 deletions Lib/test/test_locale.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -373,13 +373,19 @@ def setUp(self):

@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'))

Expand Down
8 changes: 6 additions & 2 deletions Lib/test/test_pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
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

Expand Down Expand Up @@ -1356,7 +1357,10 @@ def a_fn_with_https_link():
)


@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"""

Expand Down
3 changes: 2 additions & 1 deletion Lib/test/test_pyexpat.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
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):
Expand Down Expand Up @@ -469,6 +469,7 @@ def test_exception(self):
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])

Expand Down
12 changes: 9 additions & 3 deletions Lib/test/test_re.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -1943,7 +1943,10 @@ def test_bug_20998(self):
# 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)
Expand Down Expand Up @@ -1980,7 +1983,10 @@ def check_en_US_utf8(self):
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)
Expand Down
5 changes: 3 additions & 2 deletions Lib/test/test_robotparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,9 @@ def log_message(self, format, *args):
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):

Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_selectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
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'):
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ def test_print_warning(self):
'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)
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
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
Expand All @@ -35,8 +35,8 @@
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):
Expand Down