summaryrefslogtreecommitdiffstats
path: root/Lib/unittest
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2022-03-22 10:04:36 (GMT)
committerGitHub <noreply@github.com>2022-03-22 10:04:36 (GMT)
commitdeeaac49e267285158264643799624623f4a7b29 (patch)
tree27f409d7d43cf169451aa892a2363f1cac85f7df /Lib/unittest
parenta25a985535ccbb7df8caddc0017550ff4eae5855 (diff)
downloadcpython-deeaac49e267285158264643799624623f4a7b29.zip
cpython-deeaac49e267285158264643799624623f4a7b29.tar.gz
cpython-deeaac49e267285158264643799624623f4a7b29.tar.bz2
bpo-40280: Skip socket, fork, subprocess tests on Emscripten (GH-31986)
- Add requires_fork and requires_subprocess to more tests - Skip extension import tests if dlopen is not available - Don't assume that _testcapi is a shared extension - Skip a lot of socket tests that don't work on Emscripten - Skip mmap tests, mmap emulation is incomplete - venv does not work yet - Cannot get libc from executable The "entire" test suite is now passing on Emscripten with EMSDK from git head (91 suites are skipped).
Diffstat (limited to 'Lib/unittest')
-rw-r--r--Lib/unittest/test/__init__.py5
-rw-r--r--Lib/unittest/test/test_async_case.py2
-rw-r--r--Lib/unittest/test/test_program.py1
-rw-r--r--Lib/unittest/test/test_runner.py2
-rw-r--r--Lib/unittest/test/testmock/testasync.py3
5 files changed, 12 insertions, 1 deletions
diff --git a/Lib/unittest/test/__init__.py b/Lib/unittest/test/__init__.py
index cdae8a7..143f4ab 100644
--- a/Lib/unittest/test/__init__.py
+++ b/Lib/unittest/test/__init__.py
@@ -11,7 +11,10 @@ def suite():
for fn in os.listdir(here):
if fn.startswith("test") and fn.endswith(".py"):
modname = "unittest.test." + fn[:-3]
- __import__(modname)
+ try:
+ __import__(modname)
+ except unittest.SkipTest:
+ continue
module = sys.modules[modname]
suite.addTest(loader.loadTestsFromModule(module))
suite.addTest(loader.loadTestsFromName('unittest.test.testmock'))
diff --git a/Lib/unittest/test/test_async_case.py b/Lib/unittest/test/test_async_case.py
index 7dc8a6b..a481408 100644
--- a/Lib/unittest/test/test_async_case.py
+++ b/Lib/unittest/test/test_async_case.py
@@ -3,6 +3,8 @@ import contextvars
import unittest
from test import support
+support.requires_working_socket(module=True)
+
class MyException(Exception):
pass
diff --git a/Lib/unittest/test/test_program.py b/Lib/unittest/test/test_program.py
index fa9e629..126497a 100644
--- a/Lib/unittest/test/test_program.py
+++ b/Lib/unittest/test/test_program.py
@@ -196,6 +196,7 @@ class FakeRunner(object):
return RESULT
+@support.requires_subprocess()
class TestCommandLineArgs(unittest.TestCase):
def setUp(self):
diff --git a/Lib/unittest/test/test_runner.py b/Lib/unittest/test/test_runner.py
index c487e9e..18062ae 100644
--- a/Lib/unittest/test/test_runner.py
+++ b/Lib/unittest/test/test_runner.py
@@ -3,6 +3,7 @@ import os
import sys
import pickle
import subprocess
+from test import support
import unittest
from unittest.case import _Outcome
@@ -1139,6 +1140,7 @@ class Test_TextTestRunner(unittest.TestCase):
expectedresult = (runner.stream, DESCRIPTIONS, VERBOSITY)
self.assertEqual(runner._makeResult(), expectedresult)
+ @support.requires_subprocess()
def test_warnings(self):
"""
Check that warnings argument of TextTestRunner correctly affects the
diff --git a/Lib/unittest/test/testmock/testasync.py b/Lib/unittest/test/testmock/testasync.py
index 122e695..1bab671 100644
--- a/Lib/unittest/test/testmock/testasync.py
+++ b/Lib/unittest/test/testmock/testasync.py
@@ -4,6 +4,9 @@ import inspect
import re
import unittest
from contextlib import contextmanager
+from test import support
+
+support.requires_working_socket(module=True)
from asyncio import run, iscoroutinefunction
from unittest import IsolatedAsyncioTestCase