|
19 | 19 | import platform
|
20 | 20 | import re
|
21 | 21 | import shutil
|
22 |
| -# TODO: Truffle reenable me once supported (GR-9140) |
23 |
| -# import socket |
| 22 | +import socket |
24 | 23 | import stat
|
25 | 24 | import struct
|
26 |
| -# TODO: Truffle reenable me once supported (GR-9141) |
27 |
| -# import subprocess |
| 25 | +import subprocess |
28 | 26 | import sys
|
29 | 27 | import sysconfig
|
30 | 28 | import tempfile
|
@@ -628,9 +626,7 @@ def wrapper(*args, **kw):
|
628 | 626 | HOSTv6 = "::1"
|
629 | 627 |
|
630 | 628 |
|
631 |
| -# TODO: revert me once socket is implemented (GR-9140) |
632 |
| -# def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM): |
633 |
| -def find_unused_port(family, socktype): |
| 629 | +def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM): |
634 | 630 | """Returns an unused port that should be suitable for binding. This is
|
635 | 631 | achieved by creating a temporary socket with the same family and type as
|
636 | 632 | the 'sock' parameter (default is AF_INET, SOCK_STREAM), and binding it to
|
@@ -738,24 +734,22 @@ def bind_unix_socket(sock, addr):
|
738 | 734 | sock.close()
|
739 | 735 | raise unittest.SkipTest('cannot bind AF_UNIX sockets')
|
740 | 736 |
|
741 |
| -# TODO: reenable me once socket is implemented (GR-9140) |
742 |
| -# def _is_ipv6_enabled(): |
743 |
| -# """Check whether IPv6 is enabled on this host.""" |
744 |
| -# if socket.has_ipv6: |
745 |
| -# sock = None |
746 |
| -# try: |
747 |
| -# sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) |
748 |
| -# sock.bind((HOSTv6, 0)) |
749 |
| -# return True |
750 |
| -# except OSError: |
751 |
| -# pass |
752 |
| -# finally: |
753 |
| -# if sock: |
754 |
| -# sock.close() |
755 |
| -# return False |
756 |
| -# |
757 |
| -# IPV6_ENABLED = _is_ipv6_enabled() |
758 |
| -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() |
759 | 753 |
|
760 | 754 | def system_must_validate_cert(f):
|
761 | 755 | """Skip the test on TLS certificate validation failures."""
|
|
0 commit comments