Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Lib/asyncio/base_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1285,8 +1285,8 @@ async def create_datagram_endpoint(self, protocol_factory,
addr_infos = {} # Using order preserving dict
for idx, addr in ((0, local_addr), (1, remote_addr)):
if addr is not None:
assert isinstance(addr, tuple) and len(addr) == 2, (
'2-tuple is expected')
if not (isinstance(addr, tuple) and len(addr) == 2):
raise TypeError('2-tuple is expected')

infos = await self._ensure_resolved(
addr, family=family, type=socket.SOCK_DGRAM,
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_asyncio/test_base_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1595,11 +1595,11 @@ def test_create_datagram_endpoint_addr_error(self):
coro = self.loop.create_datagram_endpoint(
MyDatagramProto, local_addr='localhost')
self.assertRaises(
AssertionError, self.loop.run_until_complete, coro)
TypeError, self.loop.run_until_complete, coro)
coro = self.loop.create_datagram_endpoint(
MyDatagramProto, local_addr=('localhost', 1, 2, 3))
self.assertRaises(
AssertionError, self.loop.run_until_complete, coro)
TypeError, self.loop.run_until_complete, coro)

def test_create_datagram_endpoint_connect_err(self):
self.loop.sock_connect = mock.Mock()
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_asyncio/test_proactor_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def test_loop_reading_data(self):
self.loop._proactor.recv_into.assert_called_with(self.sock, called_buf)
self.protocol.data_received.assert_called_with(bytearray(buf))

@unittest.skipIf(sys.flags.optimize, "Assertions are disabled in optimized mode")
def test_loop_reading_no_data(self):
res = self.loop.create_future()
res.set_result(0)
Expand Down Expand Up @@ -869,6 +870,7 @@ def test_datagram_loop_reading_data(self):
self.protocol.datagram_received.assert_called_with(b'data', ('127.0.0.1', 12068))
close_transport(tr)

@unittest.skipIf(sys.flags.optimize, "Assertions are disabled in optimized mode")
def test_datagram_loop_reading_no_data(self):
res = self.loop.create_future()
res.set_result((b'', ('127.0.0.1', 12068)))
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_asyncio/test_selector_events.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Tests for selector_events.py"""

import sys
import selectors
import socket
import unittest
Expand Down Expand Up @@ -804,6 +805,7 @@ def test_write_ready_closing(self):
self.sock.close.assert_called_with()
self.protocol.connection_lost.assert_called_with(None)

@unittest.skipIf(sys.flags.optimize, "Assertions are disabled in optimized mode")
def test_write_ready_no_data(self):
transport = self.socket_transport()
# This is an internal error.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed :mod:`asyncio` tests in python optimized mode. Patch by Kumar Aditya.