Skip to content

Refactor: Use is_wasm32 flag for is_emscripten or is_wasi for generic checks #136815

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 7 commits into from
Jul 22, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
common is_wasm flag for is_emscripten or is_wasi
  • Loading branch information
anistark committed Jul 19, 2025
commit f9321757a50dda9d43e0293a1eabffc91d3e2576
1 change: 1 addition & 0 deletions Lib/test/pythoninfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 5 additions & 1 deletion Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_build_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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."""

Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_import/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_pathlib/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_pty.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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

# 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
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_pydoc/test_pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
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 @@ -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())
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy