summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2022-05-23 08:39:57 (GMT)
committerGitHub <noreply@github.com>2022-05-23 08:39:57 (GMT)
commit760ec8940aabd6a7fc471bd913ea1ac501cc604b (patch)
treeee95f9ffb3214de69ea0e220c577a05c65d1e4e0 /Lib
parent88f0d0c1e8fdda036f3f64b0048911ba28ce7f06 (diff)
downloadcpython-760ec8940aabd6a7fc471bd913ea1ac501cc604b.zip
cpython-760ec8940aabd6a7fc471bd913ea1ac501cc604b.tar.gz
cpython-760ec8940aabd6a7fc471bd913ea1ac501cc604b.tar.bz2
gh-90473: WASI: skip gethostname tests (GH-93092)
- WASI's ``gethostname()`` is a stub that always fails with OSError ``ENOTSUP`` - skip mailcap ``test`` if subprocess is not available - WASI process_time clock does not work.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/support/socket_helper.py3
-rw-r--r--Lib/test/test_mailbox.py5
-rw-r--r--Lib/test/test_mailcap.py4
-rw-r--r--Lib/test/test_smtpd.py3
-rw-r--r--Lib/test/test_support.py1
-rw-r--r--Lib/test/test_time.py3
-rw-r--r--Lib/test/test_urllib.py5
-rw-r--r--Lib/test/test_urllib_response.py5
8 files changed, 29 insertions, 0 deletions
diff --git a/Lib/test/support/socket_helper.py b/Lib/test/support/socket_helper.py
index 754af18..42b2a93 100644
--- a/Lib/test/support/socket_helper.py
+++ b/Lib/test/support/socket_helper.py
@@ -11,6 +11,9 @@ HOST = "localhost"
HOSTv4 = "127.0.0.1"
HOSTv6 = "::1"
+# WASI SDK 15.0 does not provide gethostname, stub raises OSError ENOTSUP.
+has_gethostname = not support.is_wasi
+
def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
"""Returns an unused port that should be suitable for binding. This is
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
index 20c460e..07c2764 100644
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -10,12 +10,17 @@ import io
import tempfile
from test import support
from test.support import os_helper
+from test.support import socket_helper
import unittest
import textwrap
import mailbox
import glob
+if not socket_helper.has_gethostname:
+ raise unittest.SkipTest("test requires gethostname()")
+
+
class TestBase:
all_mailbox_types = (mailbox.Message, mailbox.MaildirMessage,
diff --git a/Lib/test/test_mailcap.py b/Lib/test/test_mailcap.py
index 97a8fac..d3995b1 100644
--- a/Lib/test/test_mailcap.py
+++ b/Lib/test/test_mailcap.py
@@ -221,6 +221,10 @@ class FindmatchTest(unittest.TestCase):
@unittest.skipUnless(os.name == "posix", "Requires 'test' command on system")
@unittest.skipIf(sys.platform == "vxworks", "'test' command is not supported on VxWorks")
+ @unittest.skipUnless(
+ test.support.has_subprocess_support,
+ "'test' command needs process support."
+ )
def test_test(self):
# findmatch() will automatically check any "test" conditions and skip
# the entry if the check fails.
diff --git a/Lib/test/test_smtpd.py b/Lib/test/test_smtpd.py
index 57eb98e..39ff879 100644
--- a/Lib/test/test_smtpd.py
+++ b/Lib/test/test_smtpd.py
@@ -10,6 +10,9 @@ import io
smtpd = warnings_helper.import_deprecated('smtpd')
asyncore = warnings_helper.import_deprecated('asyncore')
+if not socket_helper.has_gethostname:
+ raise unittest.SkipTest("test requires gethostname()")
+
class DummyServer(smtpd.SMTPServer):
def __init__(self, *args, **kwargs):
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index 7a8b681..23bccee 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -664,6 +664,7 @@ class TestSupport(unittest.TestCase):
self.assertTrue(support.match_test(test_chdir))
@unittest.skipIf(support.is_emscripten, "Unstable in Emscripten")
+ @unittest.skipIf(support.is_wasi, "Unavailable on WASI")
def test_fd_count(self):
# We cannot test the absolute value of fd_count(): on old Linux
# kernel or glibc versions, os.urandom() keeps a FD open on
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py
index dc0bbb0..884b142 100644
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -489,6 +489,9 @@ class TimeTestCase(unittest.TestCase):
def test_perf_counter(self):
time.perf_counter()
+ @unittest.skipIf(
+ support.is_wasi, "process_time not available on WASI"
+ )
def test_process_time(self):
# process_time() should not include time spend during a sleep
start = time.process_time()
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
index bc6e74c..f067560 100644
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -10,6 +10,7 @@ import unittest
from unittest.mock import patch
from test import support
from test.support import os_helper
+from test.support import socket_helper
from test.support import warnings_helper
import os
try:
@@ -24,6 +25,10 @@ from base64 import b64encode
import collections
+if not socket_helper.has_gethostname:
+ raise unittest.SkipTest("test requires gethostname()")
+
+
def hexescape(char):
"""Escape char as RFC 2396 specifies"""
hex_repr = hex(ord(char))[2:].upper()
diff --git a/Lib/test/test_urllib_response.py b/Lib/test/test_urllib_response.py
index 73d2ef0..b76763f 100644
--- a/Lib/test/test_urllib_response.py
+++ b/Lib/test/test_urllib_response.py
@@ -4,6 +4,11 @@ import socket
import tempfile
import urllib.response
import unittest
+from test import support
+
+if support.is_wasi:
+ raise unittest.SkipTest("Cannot create socket on WASI")
+
class TestResponse(unittest.TestCase):