Skip to content

Commit 70c552c

Browse files
committed
Fix uvloop tests under 3.5.2
1 parent 4e3065c commit 70c552c

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

tests/test_sockets.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import asyncio
22
import socket
3+
import sys
4+
import unittest
35

46
from uvloop import _testbase as tb
57

@@ -16,6 +18,10 @@ async def recv_all(self, sock, nbytes):
1618
return buf
1719

1820
def test_socket_connect_recv_send(self):
21+
if self.is_asyncio_loop() and sys.version_info[:3] == (3, 5, 2):
22+
# See https://github.com/python/asyncio/pull/366 for details.
23+
raise unittest.SkipTest()
24+
1925
def srv_gen():
2026
yield tb.write(b'helo')
2127
data = yield tb.read(4 * _SIZE)

tests/test_tcp.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
class _TestTCP:
1111
def test_create_server_1(self):
12+
if self.is_asyncio_loop() and sys.version_info[:3] == (3, 5, 2):
13+
# See https://github.com/python/asyncio/pull/366 for details.
14+
raise unittest.SkipTest()
15+
1216
CNT = 0 # number of clients that were successful
1317
TOTAL_CNT = 25 # total number of clients that test will create
1418
TIMEOUT = 5.0 # timeout for this test

uvloop/_patch.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12
import sys
23

34

@@ -55,20 +56,15 @@ async def _wait_for_data(self, func_name):
5556
self._waiter = None
5657

5758

58-
if sys.version_info < (3, 5, 2):
59-
# In Python 3.5.2 (see PEP 478 for 3.5 release schedule)
60-
# we won't need to patch anything.
61-
62-
import asyncio
63-
64-
from asyncio import coroutines
65-
from asyncio import streams
66-
59+
if sys.version_info < (3, 5, 3):
6760
# This is needed to support Cython 'async def' coroutines.
61+
from asyncio import coroutines
6862
_old_format_coroutine = coroutines._format_coroutine
6963
coroutines._format_coroutine = _format_coroutine
7064

65+
if sys.version_info < (3, 5, 2):
7166
# Fix a possible deadlock, improve performance.
67+
from asyncio import streams
7268
_old_wait_for_data = streams.StreamReader._wait_for_data
7369
_wait_for_data.__module__ = _old_wait_for_data.__module__
7470
streams.StreamReader._wait_for_data = _wait_for_data

uvloop/_testbase.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ def new_loop(self):
6363
def mock_pattern(self, str):
6464
return MockPattern(str)
6565

66+
def is_asyncio_loop(self):
67+
return type(self.loop).__module__.startswith('asyncio.')
68+
6669
def setUp(self):
6770
self.loop = self.new_loop()
6871
asyncio.set_event_loop(self.loop)

0 commit comments

Comments
 (0)