From f9321757a50dda9d43e0293a1eabffc91d3e2576 Mon Sep 17 00:00:00 2001 From: Kumar Anirudha Date: Sat, 19 Jul 2025 15:27:43 +0200 Subject: [PATCH 1/3] common is_wasm flag for is_emscripten or is_wasi --- Lib/test/pythoninfo.py | 1 + Lib/test/support/__init__.py | 6 +++++- Lib/test/test_build_details.py | 4 ++-- Lib/test/test_import/__init__.py | 4 ++-- Lib/test/test_pathlib/test_pathlib.py | 6 +++--- Lib/test/test_pty.py | 4 ++-- Lib/test/test_pydoc/test_pydoc.py | 4 ++-- Lib/test/test_support.py | 2 +- Lib/test/test_venv.py | 4 ++-- 9 files changed, 20 insertions(+), 15 deletions(-) diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py index 80a262c18a5ad2..83b738b6e81e2d 100644 --- a/Lib/test/pythoninfo.py +++ b/Lib/test/pythoninfo.py @@ -762,6 +762,7 @@ def collect_support(info_add): 'is_emscripten', 'is_jython', 'is_wasi', + 'is_wasm', ) copy_attributes(info_add, support, 'support.%s', attributes) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 196a2e5c600e24..1c999a11f4ad9f 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -569,6 +569,9 @@ def skip_android_selinux(name): is_emscripten = sys.platform == "emscripten" is_wasi = sys.platform == "wasi" +# Use is_wasm as a generic check for WebAssembly platforms. +is_wasm = is_emscripten or is_wasi + def skip_emscripten_stack_overflow(): return unittest.skipIf(is_emscripten, "Exhausts stack on Emscripten") @@ -3148,7 +3151,8 @@ def linked_to_musl(): # emscripten (at least as far as we're concerned) and wasi use musl, # but platform doesn't know how to get the version, so set it to zero. - if is_emscripten or is_wasi: + # set zero for wasm in general. + if is_wasm: _linked_to_musl = (0, 0, 0) return _linked_to_musl diff --git a/Lib/test/test_build_details.py b/Lib/test/test_build_details.py index ba4b8c5aa9b58e..03985282aa8b75 100644 --- a/Lib/test/test_build_details.py +++ b/Lib/test/test_build_details.py @@ -5,7 +5,7 @@ import string import unittest -from test.support import is_android, is_apple_mobile, is_emscripten, is_wasi +from test.support import is_android, is_apple_mobile, is_wasm class FormatTestsBase: @@ -91,7 +91,7 @@ def test_implementation(self): @unittest.skipIf(os.name != 'posix', 'Feature only implemented on POSIX right now') -@unittest.skipIf(is_wasi or is_emscripten, 'Feature not available on WebAssembly builds') +@unittest.skipIf(is_wasm, 'Feature not available on WebAssembly builds') class CPythonBuildDetailsTests(unittest.TestCase, FormatTestsBase): """Test CPython's install details file implementation.""" diff --git a/Lib/test/test_import/__init__.py b/Lib/test/test_import/__init__.py index 6e34094c5aa422..d2c418a150b742 100644 --- a/Lib/test/test_import/__init__.py +++ b/Lib/test/test_import/__init__.py @@ -35,7 +35,7 @@ cpython_only, is_apple_mobile, is_emscripten, - is_wasi, + is_wasm, run_in_subinterp, run_in_subinterp_with_config, Py_TRACE_REFS, @@ -1257,7 +1257,7 @@ class FilePermissionTests(unittest.TestCase): @unittest.skipUnless(os.name == 'posix', "test meaningful only on posix systems") @unittest.skipIf( - is_emscripten or is_wasi, + is_wasm, "Emscripten's/WASI's umask is a stub." ) def test_creation_mode(self): diff --git a/Lib/test/test_pathlib/test_pathlib.py b/Lib/test/test_pathlib/test_pathlib.py index b2e2cdb3338beb..bbd6b6624becca 100644 --- a/Lib/test/test_pathlib/test_pathlib.py +++ b/Lib/test/test_pathlib/test_pathlib.py @@ -17,7 +17,7 @@ from test.support import import_helper from test.support import cpython_only -from test.support import is_emscripten, is_wasi +from test.support import is_emscripten, is_wasi, is_wasm from test.support import infinite_recursion from test.support import os_helper from test.support.os_helper import TESTFN, FS_NONASCII, FakePath @@ -3164,7 +3164,7 @@ def test_absolute_posix(self): self.assertEqual(str(P('//a/b').absolute()), '//a/b') @unittest.skipIf( - is_emscripten or is_wasi, + is_wasm, "umask is not implemented on Emscripten/WASI." ) @needs_posix @@ -3195,7 +3195,7 @@ def test_resolve_root(self): os.chdir(current_directory) @unittest.skipIf( - is_emscripten or is_wasi, + is_wasm, "umask is not implemented on Emscripten/WASI." ) @needs_posix diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py index 4836f38c388c05..9a40f0e4281d66 100644 --- a/Lib/test/test_pty.py +++ b/Lib/test/test_pty.py @@ -1,6 +1,6 @@ import unittest from test.support import ( - is_android, is_apple_mobile, is_emscripten, is_wasi, reap_children, verbose + is_android, is_apple_mobile, is_wasm, reap_children, verbose ) from test.support.import_helper import import_module from test.support.os_helper import TESTFN, unlink @@ -8,7 +8,7 @@ # Skip these tests if termios is not available import_module('termios') -if is_android or is_apple_mobile or is_emscripten or is_wasi: +if is_android or is_apple_mobile or is_wasm: raise unittest.SkipTest("pty is not available on this platform") import errno diff --git a/Lib/test/test_pydoc/test_pydoc.py b/Lib/test/test_pydoc/test_pydoc.py index 005526d994bd62..0928c1a71da478 100644 --- a/Lib/test/test_pydoc/test_pydoc.py +++ b/Lib/test/test_pydoc/test_pydoc.py @@ -33,7 +33,7 @@ assert_python_failure, spawn_python) from test.support import threading_helper from test.support import (reap_children, captured_stdout, - captured_stderr, is_emscripten, is_wasi, + captured_stderr, is_wasm, requires_docstrings, MISSING_C_DOCSTRINGS) from test.support.os_helper import (TESTFN, rmtree, unlink) from test.test_pydoc import pydoc_mod @@ -2081,7 +2081,7 @@ def test_html_doc_routines_in_module(self): @unittest.skipIf( - is_emscripten or is_wasi, + is_wasm, "Socket server not available on Emscripten/WASI." ) class PydocServerTest(unittest.TestCase): diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index cb31122fee9642..5a847fcc2b21dc 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -786,7 +786,7 @@ def test_get_signal_name(self): def test_linked_to_musl(self): linked = support.linked_to_musl() self.assertIsNotNone(linked) - if support.is_wasi or support.is_emscripten: + if support.is_wasm: self.assertTrue(linked) # The value is cached, so make sure it returns the same value again. self.assertIs(linked, support.linked_to_musl()) diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index d62f3fba2d1a94..1eb8b5b5d383b5 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -21,7 +21,7 @@ from test.support import (captured_stdout, captured_stderr, skip_if_broken_multiprocessing_synchronize, verbose, requires_subprocess, is_android, is_apple_mobile, - is_emscripten, is_wasi, + is_wasm, requires_venv_with_pip, TEST_HOME_DIR, requires_resource, copy_python_src_ignore) from test.support.os_helper import (can_symlink, EnvironmentVarGuard, rmtree, @@ -42,7 +42,7 @@ or sys._base_executable != sys.executable, 'cannot run venv.create from within a venv on this platform') -if is_android or is_apple_mobile or is_emscripten or is_wasi: +if is_android or is_apple_mobile or is_wasm: raise unittest.SkipTest("venv is not available on this platform") @requires_subprocess() From 96a9abbc9498fd056a5c7feead6e8ed5866a78f9 Mon Sep 17 00:00:00 2001 From: Kumar Anirudha Date: Sat, 19 Jul 2025 23:18:19 +0200 Subject: [PATCH 2/3] is_wasm->is_wasm32 --- Lib/test/pythoninfo.py | 2 +- Lib/test/support/__init__.py | 6 +++--- Lib/test/test_build_details.py | 4 ++-- Lib/test/test_import/__init__.py | 4 ++-- Lib/test/test_pathlib/test_pathlib.py | 6 +++--- Lib/test/test_pty.py | 4 ++-- Lib/test/test_pydoc/test_pydoc.py | 4 ++-- Lib/test/test_support.py | 2 +- Lib/test/test_venv.py | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py index 83b738b6e81e2d..e8718decf6d6e9 100644 --- a/Lib/test/pythoninfo.py +++ b/Lib/test/pythoninfo.py @@ -762,7 +762,7 @@ def collect_support(info_add): 'is_emscripten', 'is_jython', 'is_wasi', - 'is_wasm', + 'is_wasm32', ) copy_attributes(info_add, support, 'support.%s', attributes) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 1c999a11f4ad9f..4386d3d7904c29 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -569,8 +569,8 @@ def skip_android_selinux(name): is_emscripten = sys.platform == "emscripten" is_wasi = sys.platform == "wasi" -# Use is_wasm as a generic check for WebAssembly platforms. -is_wasm = is_emscripten or is_wasi +# Use is_wasm32 as a generic check for WebAssembly platforms. +is_wasm32 = is_emscripten or is_wasi def skip_emscripten_stack_overflow(): return unittest.skipIf(is_emscripten, "Exhausts stack on Emscripten") @@ -3152,7 +3152,7 @@ def linked_to_musl(): # emscripten (at least as far as we're concerned) and wasi use musl, # but platform doesn't know how to get the version, so set it to zero. # set zero for wasm in general. - if is_wasm: + if is_wasm32: _linked_to_musl = (0, 0, 0) return _linked_to_musl diff --git a/Lib/test/test_build_details.py b/Lib/test/test_build_details.py index 03985282aa8b75..8c5a400a2950c3 100644 --- a/Lib/test/test_build_details.py +++ b/Lib/test/test_build_details.py @@ -5,7 +5,7 @@ import string import unittest -from test.support import is_android, is_apple_mobile, is_wasm +from test.support import is_android, is_apple_mobile, is_wasm32 class FormatTestsBase: @@ -91,7 +91,7 @@ def test_implementation(self): @unittest.skipIf(os.name != 'posix', 'Feature only implemented on POSIX right now') -@unittest.skipIf(is_wasm, 'Feature not available on WebAssembly builds') +@unittest.skipIf(is_wasm32, 'Feature not available on WebAssembly builds') class CPythonBuildDetailsTests(unittest.TestCase, FormatTestsBase): """Test CPython's install details file implementation.""" diff --git a/Lib/test/test_import/__init__.py b/Lib/test/test_import/__init__.py index d2c418a150b742..abbd5f1ed5f12f 100644 --- a/Lib/test/test_import/__init__.py +++ b/Lib/test/test_import/__init__.py @@ -35,7 +35,7 @@ cpython_only, is_apple_mobile, is_emscripten, - is_wasm, + is_wasm32, run_in_subinterp, run_in_subinterp_with_config, Py_TRACE_REFS, @@ -1257,7 +1257,7 @@ class FilePermissionTests(unittest.TestCase): @unittest.skipUnless(os.name == 'posix', "test meaningful only on posix systems") @unittest.skipIf( - is_wasm, + is_wasm32, "Emscripten's/WASI's umask is a stub." ) def test_creation_mode(self): diff --git a/Lib/test/test_pathlib/test_pathlib.py b/Lib/test/test_pathlib/test_pathlib.py index bbd6b6624becca..177646724b0731 100644 --- a/Lib/test/test_pathlib/test_pathlib.py +++ b/Lib/test/test_pathlib/test_pathlib.py @@ -17,7 +17,7 @@ from test.support import import_helper from test.support import cpython_only -from test.support import is_emscripten, is_wasi, is_wasm +from test.support import is_emscripten, is_wasi, is_wasm32 from test.support import infinite_recursion from test.support import os_helper from test.support.os_helper import TESTFN, FS_NONASCII, FakePath @@ -3164,7 +3164,7 @@ def test_absolute_posix(self): self.assertEqual(str(P('//a/b').absolute()), '//a/b') @unittest.skipIf( - is_wasm, + is_wasm32, "umask is not implemented on Emscripten/WASI." ) @needs_posix @@ -3195,7 +3195,7 @@ def test_resolve_root(self): os.chdir(current_directory) @unittest.skipIf( - is_wasm, + is_wasm32, "umask is not implemented on Emscripten/WASI." ) @needs_posix diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py index 9a40f0e4281d66..ed4fe8a140879d 100644 --- a/Lib/test/test_pty.py +++ b/Lib/test/test_pty.py @@ -1,6 +1,6 @@ import unittest from test.support import ( - is_android, is_apple_mobile, is_wasm, reap_children, verbose + is_android, is_apple_mobile, is_wasm32, reap_children, verbose ) from test.support.import_helper import import_module from test.support.os_helper import TESTFN, unlink @@ -8,7 +8,7 @@ # Skip these tests if termios is not available import_module('termios') -if is_android or is_apple_mobile or is_wasm: +if is_android or is_apple_mobile or is_wasm32: raise unittest.SkipTest("pty is not available on this platform") import errno diff --git a/Lib/test/test_pydoc/test_pydoc.py b/Lib/test/test_pydoc/test_pydoc.py index 0928c1a71da478..3b50ead00bdd31 100644 --- a/Lib/test/test_pydoc/test_pydoc.py +++ b/Lib/test/test_pydoc/test_pydoc.py @@ -33,7 +33,7 @@ assert_python_failure, spawn_python) from test.support import threading_helper from test.support import (reap_children, captured_stdout, - captured_stderr, is_wasm, + captured_stderr, is_wasm32, requires_docstrings, MISSING_C_DOCSTRINGS) from test.support.os_helper import (TESTFN, rmtree, unlink) from test.test_pydoc import pydoc_mod @@ -2081,7 +2081,7 @@ def test_html_doc_routines_in_module(self): @unittest.skipIf( - is_wasm, + is_wasm32, "Socket server not available on Emscripten/WASI." ) class PydocServerTest(unittest.TestCase): diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index 5a847fcc2b21dc..f3d7b46535395a 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -786,7 +786,7 @@ def test_get_signal_name(self): def test_linked_to_musl(self): linked = support.linked_to_musl() self.assertIsNotNone(linked) - if support.is_wasm: + if support.is_wasm32: self.assertTrue(linked) # The value is cached, so make sure it returns the same value again. self.assertIs(linked, support.linked_to_musl()) diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index 1eb8b5b5d383b5..3c18c9c2900ad7 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -21,7 +21,7 @@ from test.support import (captured_stdout, captured_stderr, skip_if_broken_multiprocessing_synchronize, verbose, requires_subprocess, is_android, is_apple_mobile, - is_wasm, + is_wasm32, requires_venv_with_pip, TEST_HOME_DIR, requires_resource, copy_python_src_ignore) from test.support.os_helper import (can_symlink, EnvironmentVarGuard, rmtree, @@ -42,7 +42,7 @@ or sys._base_executable != sys.executable, 'cannot run venv.create from within a venv on this platform') -if is_android or is_apple_mobile or is_wasm: +if is_android or is_apple_mobile or is_wasm32: raise unittest.SkipTest("venv is not available on this platform") @requires_subprocess() From aea29e12f9f077400115907c685638015b7b9dcc Mon Sep 17 00:00:00 2001 From: Ani <5357586+anistark@users.noreply.github.com> Date: Tue, 22 Jul 2025 02:15:08 +0530 Subject: [PATCH 3/3] Update Lib/test/support/__init__.py Co-authored-by: Brett Cannon --- Lib/test/support/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 4386d3d7904c29..100438bf71d3a6 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -3151,7 +3151,6 @@ def linked_to_musl(): # emscripten (at least as far as we're concerned) and wasi use musl, # but platform doesn't know how to get the version, so set it to zero. - # set zero for wasm in general. if is_wasm32: _linked_to_musl = (0, 0, 0) return _linked_to_musl