Skip to content

Commit 5074241

Browse files
miss-islingtonanistarkbrettcannon
authored
[3.14] Use test.support.is_wasm32 flag for is_emscripten or is_wasi for generic checks (pythonGH-136815) (python#138643)
Co-authored-by: Ani <[email protected]> Co-authored-by: Brett Cannon <[email protected]>
1 parent f23e760 commit 5074241

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
@@ -752,6 +752,7 @@ def collect_support(info_add):
752752
'is_emscripten',
753753
'is_jython',
754754
'is_wasi',
755+
'is_wasm32',
755756
)
756757
copy_attributes(info_add, support, 'support.%s', attributes)
757758

Lib/test/support/__init__.py

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

577+
# Use is_wasm32 as a generic check for WebAssembly platforms.
578+
is_wasm32 = is_emscripten or is_wasi
579+
577580
def skip_emscripten_stack_overflow():
578581
return unittest.skipIf(is_emscripten, "Exhausts stack on Emscripten")
579582

@@ -3154,7 +3157,7 @@ def linked_to_musl():
31543157

31553158
# emscripten (at least as far as we're concerned) and wasi use musl,
31563159
# but platform doesn't know how to get the version, so set it to zero.
3157-
if is_emscripten or is_wasi:
3160+
if is_wasm32:
31583161
_linked_to_musl = (0, 0, 0)
31593162
return _linked_to_musl
31603163

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
@@ -3164,7 +3164,7 @@ def test_absolute_posix(self):
31643164
self.assertEqual(str(P('//a/b').absolute()), '//a/b')
31653165

31663166
@unittest.skipIf(
3167-
is_emscripten or is_wasi,
3167+
is_wasm32,
31683168
"umask is not implemented on Emscripten/WASI."
31693169
)
31703170
@needs_posix
@@ -3195,7 +3195,7 @@ def test_resolve_root(self):
31953195
os.chdir(current_directory)
31963196

31973197
@unittest.skipIf(
3198-
is_emscripten or is_wasi,
3198+
is_wasm32,
31993199
"umask is not implemented on Emscripten/WASI."
32003200
)
32013201
@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
@@ -784,7 +784,7 @@ def test_get_signal_name(self):
784784
def test_linked_to_musl(self):
785785
linked = support.linked_to_musl()
786786
self.assertIsNotNone(linked)
787-
if support.is_wasi or support.is_emscripten:
787+
if support.is_wasm32:
788788
self.assertTrue(linked)
789789
# The value is cached, so make sure it returns the same value again.
790790
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)