8000 gh-90473: WASI: skip gethostname tests by tiran · Pull Request #93092 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-90473: WASI: skip gethostname tests #93092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Lib/test/support/socket_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
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
Expand Down
5 changes: 5 additions & 0 deletions Lib/test/test_mailbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@
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,
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_mailcap.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ def test_findmatch(self):

@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.
Expand Down
3 changes: 3 additions & 0 deletions Lib/test/test_smtpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
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):
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ def id(self):
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
Expand Down
3 changes: 3 additions & 0 deletions Lib/test/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ def test_monotonic(self):
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()
Expand Down
5 changes: 5 additions & 0 deletions Lib/test/test_urllib.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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:
Expand All @@ -24,6 +25,10 @@
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()
Expand Down
5 changes: 5 additions & 0 deletions Lib/test/test_urllib_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
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):

Expand Down
1 change: 1 addition & 0 deletions Tools/wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ are:
yet. A future version of WASI may provide a limited ``set_permissions`` API.
- File locking (``fcntl``) is not available.
- ``os.pipe()``, ``os.mkfifo()``, and ``os.mknod()`` are not supported.
- ``process_time`` clock does not work.


# Detect WebAssembly builds
Expand Down
0