Fix uvloop tests under 3.5.2

This commit is contained in:
Yury Selivanov 2016-06-28 18:02:48 -04:00
parent 4e3065cb51
commit 70c552c9de
4 changed files with 18 additions and 9 deletions

View File

@ -1,5 +1,7 @@
import asyncio
import socket
import sys
import unittest
from uvloop import _testbase as tb
@ -16,6 +18,10 @@ class _TestSockets:
return buf
def test_socket_connect_recv_send(self):
if self.is_asyncio_loop() and sys.version_info[:3] == (3, 5, 2):
# See https://github.com/python/asyncio/pull/366 for details.
raise unittest.SkipTest()
def srv_gen():
yield tb.write(b'helo')
data = yield tb.read(4 * _SIZE)

View File

@ -9,6 +9,10 @@ from uvloop import _testbase as tb
class _TestTCP:
def test_create_server_1(self):
if self.is_asyncio_loop() and sys.version_info[:3] == (3, 5, 2):
# See https://github.com/python/asyncio/pull/366 for details.
raise unittest.SkipTest()
CNT = 0 # number of clients that were successful
TOTAL_CNT = 25 # total number of clients that test will create
TIMEOUT = 5.0 # timeout for this test

View File

@ -1,3 +1,4 @@
import asyncio
import sys
@ -55,20 +56,15 @@ async def _wait_for_data(self, func_name):
self._waiter = None
if sys.version_info < (3, 5, 2):
# In Python 3.5.2 (see PEP 478 for 3.5 release schedule)
# we won't need to patch anything.
import asyncio
from asyncio import coroutines
from asyncio import streams
if sys.version_info < (3, 5, 3):
# This is needed to support Cython 'async def' coroutines.
from asyncio import coroutines
_old_format_coroutine = coroutines._format_coroutine
coroutines._format_coroutine = _format_coroutine
if sys.version_info < (3, 5, 2):
# Fix a possible deadlock, improve performance.
from asyncio import streams
_old_wait_for_data = streams.StreamReader._wait_for_data
_wait_for_data.__module__ = _old_wait_for_data.__module__
streams.StreamReader._wait_for_data = _wait_for_data

View File

@ -63,6 +63,9 @@ class BaseTestCase(unittest.TestCase, metaclass=BaseTestCaseMeta):
def mock_pattern(self, str):
return MockPattern(str)
def is_asyncio_loop(self):
return type(self.loop).__module__.startswith('asyncio.')
def setUp(self):
self.loop = self.new_loop()
asyncio.set_event_loop(self.loop)