Skip to content

Commit aafb143

Browse files
Use test.support.is_wasm32 flag for is_emscripten or is_wasi for generic checks (GH-136815)
Co-authored-by: Brett Cannon <[email protected]>
1 parent d6cf05b commit aafb143

File tree

9 files changed

+19
-15
lines changed

9 files changed

+19
-15
lines changed

Lib/test/pythoninfo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,7 @@ def collect_support(info_add):
762762
'is_emscripten',
763763
'is_jython',
764764
'is_wasi',
765+
'is_wasm32',
765766
)
766767
copy_attributes(info_add, support, 'support.%s', attributes)
767768

Lib/test/support/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,9 @@ def skip_android_selinux(name):
569569
is_emscripten = sys.platform == "emscripten"
570570
is_wasi = sys.platform == "wasi"
571571

572+
# Use is_wasm32 as a generic check for WebAssembly platforms.
573+
is_wasm32 = is_emscripten or is_wasi
574+
572575
def skip_emscripten_stack_overflow():
573576
return unittest.skipIf(is_emscripten, "Exhausts stack on Emscripten")
574577

@@ -3148,7 +3151,7 @@ def linked_to_musl():
31483151

31493152
# emscripten (at least as far as we're concerned) and wasi use musl,
31503153
# but platform doesn't know how to get the version, so set it to zero.
3151-
if is_emscripten or is_wasi:
3154+
if is_wasm32:
31523155
_linked_to_musl = (0, 0, 0)
31533156
return _linked_to_musl
31543157

Lib/test/test_build_details.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import string
66
import unittest
77

8-
from test.support import is_android, is_apple_mobile, is_emscripten, is_wasi
8+
from test.support import is_android, is_apple_mobile, is_wasm32
99

1010

1111
class FormatTestsBase:
@@ -91,7 +91,7 @@ def test_implementation(self):
9191

9292

9393
@unittest.skipIf(os.name != 'posix', 'Feature only implemented on POSIX right now')
94-
@unittest.skipIf(is_wasi or is_emscripten, 'Feature not available on WebAssembly builds')
94+
@unittest.skipIf(is_wasm32, 'Feature not available on WebAssembly builds')
9595
class CPythonBuildDetailsTests(unittest.TestCase, FormatTestsBase):
9696
"""Test CPython's install details file implementation."""
9797

Lib/test/test_import/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
cpython_only,
3636
is_apple_mobile,
3737
is_emscripten,
38-
is_wasi,
38+
is_wasm32,
3939
run_in_subinterp,
4040
run_in_subinterp_with_config,
4141
Py_TRACE_REFS,
@@ -1257,7 +1257,7 @@ class FilePermissionTests(unittest.TestCase):
12571257
@unittest.skipUnless(os.name == 'posix',
12581258
"test meaningful only on posix systems")
12591259
@unittest.skipIf(
1260-
is_emscripten or is_wasi,
1260+
is_wasm32,
12611261
"Emscripten's/WASI's umask is a stub."
12621262
)
12631263
def test_creation_mode(self):

Lib/test/test_pathlib/test_pathlib.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from test.support import import_helper
1919
from test.support import cpython_only
20-
from test.support import is_emscripten, is_wasi
20+
from test.support import is_emscripten, is_wasi, is_wasm32
2121
from test.support import infinite_recursion
2222
from test.support import os_helper
2323
from test.support.os_helper import TESTFN, FS_NONASCII, FakePath
@@ -3158,7 +3158,7 @@ def test_absolute_posix(self):
31583158
self.assertEqual(str(P('//a/b').absolute()), '//a/b')
31593159

31603160
@unittest.skipIf(
3161-
is_emscripten or is_wasi,
3161+
is_wasm32,
31623162
"umask is not implemented on Emscripten/WASI."
31633163
)
31643164
@needs_posix
@@ -3189,7 +3189,7 @@ def test_resolve_root(self):
31893189
os.chdir(current_directory)
31903190

31913191
@unittest.skipIf(
3192-
is_emscripten or is_wasi,
3192+
is_wasm32,
31933193
"umask is not implemented on Emscripten/WASI."
31943194
)
31953195
@needs_posix

Lib/test/test_pty.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import unittest
22
from test.support import (
3-
is_android, is_apple_mobile, is_emscripten, is_wasi, reap_children, verbose
3+
is_android, is_apple_mobile, is_wasm32, reap_children, verbose
44
)
55
from test.support.import_helper import import_module
66
from test.support.os_helper import TESTFN, unlink
77

88
# Skip these tests if termios is not available
99
import_module('termios')
1010

11-
if is_android or is_apple_mobile or is_emscripten or is_wasi:
11+
if is_android or is_apple_mobile or is_wasm32:
1212
raise unittest.SkipTest("pty is not available on this platform")
1313

1414
import errno

Lib/test/test_pydoc/test_pydoc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
assert_python_failure, spawn_python)
3434
from test.support import threading_helper
3535
from test.support import (reap_children, captured_stdout,
36-
captured_stderr, is_emscripten, is_wasi,
36+
captured_stderr, is_wasm32,
3737
requires_docstrings, MISSING_C_DOCSTRINGS)
3838
from test.support.os_helper import (TESTFN, rmtree, unlink)
3939
from test.test_pydoc import pydoc_mod
@@ -2081,7 +2081,7 @@ def test_html_doc_routines_in_module(self):
20812081

20822082

20832083
@unittest.skipIf(
2084-
is_emscripten or is_wasi,
2084+
is_wasm32,
20852085
"Socket server not available on Emscripten/WASI."
20862086
)
20872087
class PydocServerTest(unittest.TestCase):

Lib/test/test_support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ def test_get_signal_name(self):
787787
def test_linked_to_musl(self):
788788
linked = support.linked_to_musl()
789789
self.assertIsNotNone(linked)
790-
if support.is_wasi or support.is_emscripten:
790+
if support.is_wasm32:
791791
self.assertTrue(linked)
792792
# The value is cached, so make sure it returns the same value again.
793793
self.assertIs(linked, support.linked_to_musl())

Lib/test/test_venv.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from test.support import (captured_stdout, captured_stderr,
2222
skip_if_broken_multiprocessing_synchronize, verbose,
2323
requires_subprocess, is_android, is_apple_mobile,
24-
is_emscripten, is_wasi,
24+
is_wasm32,
2525
requires_venv_with_pip, TEST_HOME_DIR,
2626
requires_resource, copy_python_src_ignore)
2727
from test.support.os_helper import (can_symlink, EnvironmentVarGuard, rmtree,
@@ -42,7 +42,7 @@
4242
or sys._base_executable != sys.executable,
4343
'cannot run venv.create from within a venv on this platform')
4444

45-
if is_android or is_apple_mobile or is_emscripten or is_wasi:
45+
if is_android or is_apple_mobile or is_wasm32:
4646
raise unittest.SkipTest("venv is not available on this platform")
4747

4848
@requires_subprocess()

0 commit comments

Comments
 (0)