Skip to content

Commit 3fff721

Browse files
committed
[GR-9139][GR-9143][GR-9140] Revert some of the unittest patches
PullRequest: graalpython/298
2 parents 64153b5 + 3f59723 commit 3fff721

File tree

5 files changed

+26
-35
lines changed

5 files changed

+26
-35
lines changed

graalpython/lib-graalpython/_socket.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,5 @@
4646
SOCK_RAW = 3
4747
SOCK_RDM = 4
4848
SOCK_SEQPACKET = 5
49+
50+
has_ipv6 = False #: TODO implement me

graalpython/lib-python/3/logging/handlers.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222
2323
To use, simply 'import logging.handlers' and log away!
2424
"""
25-
# TODO: Truffle reenable me once socket is supported (GR-9140)
26-
# import logging, socket, os, pickle, struct, time, re
27-
import logging, os, pickle, struct, time, re
25+
import logging, socket, os, pickle, struct, time, re
2826
from stat import ST_DEV, ST_INO, ST_MTIME
2927
# TODO: Truffle reenable me once queue and threading is supported (GR-9144)
3028
# import queue

graalpython/lib-python/3/platform.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@
113113
__version__ = '1.0.8'
114114

115115
import collections
116-
# TODO: Truffle reenable me once subprocess is supported (GR-9141)
117-
# import sys, os, re, subprocess
118-
import sys, os, re
116+
import sys, os, re, subprocess
119117

120118
import warnings
121119

graalpython/lib-python/3/test/bisect.py renamed to graalpython/lib-python/3/test/bisect_tool.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
./python -m test.bisect -i tests test_os
1818
"""
1919

20+
# TODO TRUFFLE: revert rename me back to bisect.py
2021
import argparse
2122
import datetime
2223
import os.path

graalpython/lib-python/3/test/support/__init__.py

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,18 @@
1818
import os
1919
import platform
2020
import re
21-
# TODO: Truffle reenable me once supported (GR-9139)
22-
# import shutil
23-
# TODO: Truffle reenable me once supported (GR-9140)
24-
# import socket
21+
import shutil
22+
import socket
2523
import stat
2624
import struct
27-
# TODO: Truffle reenable me once supported (GR-9141)
28-
# import subprocess
25+
import subprocess
2926
import sys
3027
import sysconfig
3128
import tempfile
3229
import time
3330
import types
3431
import unittest
35-
# TODO: Truffle reenable me once supported (GR-9143)
36-
# import urllib.error
32+
import urllib.error
3733
import warnings
3834

3935

@@ -630,9 +626,7 @@ def wrapper(*args, **kw):
630626
HOSTv6 = "::1"
631627

632628

633-
# TODO: revert me once socket is implemented (GR-9140)
634-
# def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
635-
def find_unused_port(family, socktype):
629+
def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
636630
"""Returns an unused port that should be suitable for binding. This is
637631
achieved by creating a temporary socket with the same family and type as
638632
the 'sock' parameter (default is AF_INET, SOCK_STREAM), and binding it to
@@ -740,24 +734,22 @@ def bind_unix_socket(sock, addr):
740734
sock.close()
741735
raise unittest.SkipTest('cannot bind AF_UNIX sockets')
742736

743-
# TODO: reenable me once socket is implemented (GR-9140)
744-
# def _is_ipv6_enabled():
745-
# """Check whether IPv6 is enabled on this host."""
746-
# if socket.has_ipv6:
747-
# sock = None
748-
# try:
749-
# sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
750-
# sock.bind((HOSTv6, 0))
751-
# return True
752-
# except OSError:
753-
# pass
754-
# finally:
755-
# if sock:
756-
# sock.close()
757-
# return False
758-
#
759-
# IPV6_ENABLED = _is_ipv6_enabled()
760-
IPV6_ENABLED = False
737+
def _is_ipv6_enabled():
738+
"""Check whether IPv6 is enabled on this host."""
739+
if socket.has_ipv6:
740+
sock = None
741+
try:
742+
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
743+
sock.bind((HOSTv6, 0))
744+
return True
745+
except OSError:
746+
pass
747+
finally:
748+
if sock:
749+
sock.close()
750+
return False
751+
752+
IPV6_ENABLED = _is_ipv6_enabled()
761753

762754
def system_must_validate_cert(f):
763755
"""Skip the test on TLS certificate validation failures."""

0 commit comments

Comments
 (0)