From deeaac49e267285158264643799624623f4a7b29 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Tue, 22 Mar 2022 12:04:36 +0200 Subject: 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). --- Lib/unittest/test/__init__.py | 5 ++++- Lib/unittest/test/test_async_case.py | 2 ++ Lib/unittest/test/test_program.py | 1 + Lib/unittest/test/test_runner.py | 2 ++ Lib/unittest/test/testmock/testasync.py | 3 +++ 5 files changed, 12 insertions(+), 1 deletion(-) (limited to 'Lib/unittest') diff --git a/Lib/unittest/test/__init__.py b/Lib/unittest/test/__init__.py index cdae8a7442..143f4ab5a3 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 7dc8a6bffa..a48140829c 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 fa9e6291ca..126497aa56 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 c487e9ec4e..18062ae5a5 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 122e695663..1bab671acd 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 -- cgit v1.2.1