summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2022-01-20 17:56:33 (GMT)
committerGitHub <noreply@github.com>2022-01-20 17:56:33 (GMT)
commitc02e860ee79f29905be6fca997c96bb1a404bb32 (patch)
treea4376cbc44b23a6eb5919fee929ae0a63cec1c36 /Lib
parentef3ef6fa43d5cca072eed2a66064e818de583be7 (diff)
downloadcpython-c02e860ee79f29905be6fca997c96bb1a404bb32.zip
cpython-c02e860ee79f29905be6fca997c96bb1a404bb32.tar.gz
cpython-c02e860ee79f29905be6fca997c96bb1a404bb32.tar.bz2
bpo-40280: Misc fixes for wasm32-emscripten (GH-30722)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test___all__.py17
-rw-r--r--Lib/test/test_capi.py6
-rw-r--r--Lib/test/test_compileall.py4
-rw-r--r--Lib/test/test_imp.py2
-rw-r--r--Lib/test/test_pty.py3
-rw-r--r--Lib/test/test_tracemalloc.py2
6 files changed, 29 insertions, 5 deletions
diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py
index 15f42d2..81293e1 100644
--- a/Lib/test/test___all__.py
+++ b/Lib/test/test___all__.py
@@ -3,6 +3,12 @@ from test import support
from test.support import warnings_helper
import os
import sys
+import types
+
+try:
+ import _multiprocessing
+except ModuleNotFoundError:
+ _multiprocessing = None
class NoAll(RuntimeError):
@@ -14,6 +20,17 @@ class FailedImport(RuntimeError):
class AllTest(unittest.TestCase):
+ def setUp(self):
+ # concurrent.futures uses a __getattr__ hook. Its __all__ triggers
+ # import of a submodule, which fails when _multiprocessing is not
+ # available.
+ if _multiprocessing is None:
+ sys.modules["_multiprocessing"] = types.ModuleType("_multiprocessing")
+
+ def tearDown(self):
+ if _multiprocessing is None:
+ sys.modules.pop("_multiprocessing")
+
def check_all(self, modname):
names = {}
with warnings_helper.check_warnings(
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py
index 7ada840..0957f32 100644
--- a/Lib/test/test_capi.py
+++ b/Lib/test/test_capi.py
@@ -26,6 +26,10 @@ try:
import _posixsubprocess
except ImportError:
_posixsubprocess = None
+try:
+ import _testmultiphase
+except ImportError:
+ _testmultiphase = None
# Skip this test if the _testcapi module isn't available.
_testcapi = import_helper.import_module('_testcapi')
@@ -798,6 +802,7 @@ class SubinterpreterTest(unittest.TestCase):
self.assertFalse(hasattr(binascii.Error, "foobar"))
+ @unittest.skipIf(_testmultiphase is None, "test requires _testmultiphase module")
def test_module_state_shared_in_global(self):
"""
bpo-44050: Extension module state should be shared between interpreters
@@ -991,6 +996,7 @@ class PyMemDefaultTests(PyMemDebugTests):
PYTHONMALLOC = ''
+@unittest.skipIf(_testmultiphase is None, "test requires _testmultiphase module")
class Test_ModuleStateAccess(unittest.TestCase):
"""Test access to module start (PEP 573)"""
diff --git a/Lib/test/test_compileall.py b/Lib/test/test_compileall.py
index 33f0c93..e207cf8 100644
--- a/Lib/test/test_compileall.py
+++ b/Lib/test/test_compileall.py
@@ -15,14 +15,14 @@ import time
import unittest
from unittest import mock, skipUnless
-from concurrent.futures import ProcessPoolExecutor
try:
# compileall relies on ProcessPoolExecutor if ProcessPoolExecutor exists
# and it can function.
+ from concurrent.futures import ProcessPoolExecutor
from concurrent.futures.process import _check_system_limits
_check_system_limits()
_have_multiprocessing = True
-except NotImplementedError:
+except (NotImplementedError, ModuleNotFoundError):
_have_multiprocessing = False
from test import support
diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py
index 1a21025..35e9a2a 100644
--- a/Lib/test/test_imp.py
+++ b/Lib/test/test_imp.py
@@ -23,7 +23,7 @@ def requires_load_dynamic(meth):
"""Decorator to skip a test if not running under CPython or lacking
imp.load_dynamic()."""
meth = support.cpython_only(meth)
- return unittest.skipIf(not hasattr(imp, 'load_dynamic'),
+ return unittest.skipIf(getattr(imp, 'load_dynamic', None) is None,
'imp.load_dynamic() required')(meth)
diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py
index 0c17812..0781cde 100644
--- a/Lib/test/test_pty.py
+++ b/Lib/test/test_pty.py
@@ -1,8 +1,9 @@
from test.support import verbose, reap_children
from test.support.import_helper import import_module
-# Skip these tests if termios is not available
+# Skip these tests if termios or fcntl are not available
import_module('termios')
+import_module("fcntl")
import errno
import os
diff --git a/Lib/test/test_tracemalloc.py b/Lib/test/test_tracemalloc.py
index 82be98d..d2a5ede 100644
--- a/Lib/test/test_tracemalloc.py
+++ b/Lib/test/test_tracemalloc.py
@@ -346,7 +346,7 @@ class TestTracemallocEnabled(unittest.TestCase):
# everything is fine
return 0
- @unittest.skipUnless(hasattr(os, 'fork'), 'need os.fork()')
+ @support.requires_fork()
def test_fork(self):
# check that tracemalloc is still working after fork
pid = os.fork()