Skip to content

Commit 57b3553

Browse files
committed
Fix tests under CPython 3.5.0
1 parent aebe59e commit 57b3553

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

tests/test_tcp.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import socket
44
import uvloop
55
import ssl
6+
import sys
67
import warnings
78

89
from uvloop import _testbase as tb
@@ -63,12 +64,17 @@ async def start_server():
6364
# (asyncio doesn't support multiple hosts in 3.5.0)
6465
addrs = '127.0.0.1'
6566

67+
extra = {}
68+
if hasattr(socket, 'SO_REUSEPORT') and \
69+
sys.version_info[:3] >= (3, 5, 1):
70+
extra['reuse_port'] = True
71+
6672
srv = await asyncio.start_server(
6773
handle_client,
6874
addrs, 0,
69-
reuse_port=getattr(socket, 'SO_REUSEPORT', None),
7075
family=socket.AF_INET,
71-
loop=self.loop)
76+
loop=self.loop,
77+
**extra)
7278

7379
srv_socks = srv.sockets
7480
self.assertTrue(srv_socks)

tests/test_udp.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import socket
44
import uvloop
55
import ssl
6+
import sys
67
import warnings
78

89
from asyncio import test_utils
@@ -65,11 +66,16 @@ def datagram_received(self, data, addr):
6566
self.assertEqual('INITIALIZED', server.state)
6667
self.assertIs(server.transport, s_transport)
6768

69+
extra = {}
70+
if hasattr(socket, 'SO_REUSEPORT') and \
71+
sys.version_info[:3] >= (3, 5, 1):
72+
extra['reuse_port'] = True
73+
6874
coro = self.loop.create_datagram_endpoint(
6975
lambda: MyDatagramProto(loop=self.loop),
7076
family=socket.AF_INET,
71-
reuse_port=getattr(socket, 'SO_REUSEPORT', None),
72-
remote_addr=None if lc is None else (host, port))
77+
remote_addr=None if lc is None else (host, port),
78+
**extra)
7379
transport, client = self.loop.run_until_complete(coro)
7480

7581
self.assertIsInstance(client, MyDatagramProto)

0 commit comments

Comments
 (0)