summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_asyncio/test_proactor_events.py18
-rw-r--r--Lib/test/test_asyncio/test_selector_events.py3
-rw-r--r--Lib/test/test_asyncio/test_windows_events.py3
3 files changed, 6 insertions, 18 deletions
diff --git a/Lib/test/test_asyncio/test_proactor_events.py b/Lib/test/test_asyncio/test_proactor_events.py
index 7a8b523..def08b9 100644
--- a/Lib/test/test_asyncio/test_proactor_events.py
+++ b/Lib/test/test_asyncio/test_proactor_events.py
@@ -444,15 +444,13 @@ class BaseProactorEventLoopTests(test_utils.TestCase):
self.ssock, self.csock = mock.Mock(), mock.Mock()
- class EventLoop(BaseProactorEventLoop):
- def _socketpair(s):
- return (self.ssock, self.csock)
-
- self.loop = EventLoop(self.proactor)
+ with mock.patch('asyncio.proactor_events.socket.socketpair',
+ return_value=(self.ssock, self.csock)):
+ self.loop = BaseProactorEventLoop(self.proactor)
self.set_event_loop(self.loop)
@mock.patch.object(BaseProactorEventLoop, 'call_soon')
- @mock.patch.object(BaseProactorEventLoop, '_socketpair')
+ @mock.patch('asyncio.proactor_events.socket.socketpair')
def test_ctor(self, socketpair, call_soon):
ssock, csock = socketpair.return_value = (
mock.Mock(), mock.Mock())
@@ -506,14 +504,6 @@ class BaseProactorEventLoopTests(test_utils.TestCase):
self.loop.sock_accept(self.sock)
self.proactor.accept.assert_called_with(self.sock)
- def test_socketpair(self):
- class EventLoop(BaseProactorEventLoop):
- # override the destructor to not log a ResourceWarning
- def __del__(self):
- pass
- self.assertRaises(
- NotImplementedError, EventLoop, self.proactor)
-
def test_make_socket_transport(self):
tr = self.loop._make_socket_transport(self.sock, asyncio.Protocol())
self.assertIsInstance(tr, _ProactorSocketTransport)
diff --git a/Lib/test/test_asyncio/test_selector_events.py b/Lib/test/test_asyncio/test_selector_events.py
index 2adb43a..7db943e 100644
--- a/Lib/test/test_asyncio/test_selector_events.py
+++ b/Lib/test/test_asyncio/test_selector_events.py
@@ -154,9 +154,6 @@ class BaseSelectorEventLoopTests(test_utils.TestCase):
self.loop.close()
self.assertIsNone(self.loop._selector)
- def test_socketpair(self):
- self.assertRaises(NotImplementedError, self.loop._socketpair)
-
def test_read_from_self_tryagain(self):
self.loop._ssock.recv.side_effect = BlockingIOError
self.assertIsNone(self.loop._read_from_self())
diff --git a/Lib/test/test_asyncio/test_windows_events.py b/Lib/test/test_asyncio/test_windows_events.py
index c72eef1..b70c0b7 100644
--- a/Lib/test/test_asyncio/test_windows_events.py
+++ b/Lib/test/test_asyncio/test_windows_events.py
@@ -1,4 +1,5 @@
import os
+import socket
import sys
import unittest
from unittest import mock
@@ -36,7 +37,7 @@ class ProactorTests(test_utils.TestCase):
self.set_event_loop(self.loop)
def test_close(self):
- a, b = self.loop._socketpair()
+ a, b = socket.socketpair()
trans = self.loop._make_socket_transport(a, asyncio.Protocol())
f = asyncio.ensure_future(self.loop.sock_recv(b, 100))
trans.close()