diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-11-28 11:15:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-28 11:15:26 +0100 |
commit | a10dc3efcbba8aa7cc7d1a017f8b22fc4fa8e87c (patch) | |
tree | 6ed634f185e7920ed25ae56e537e0202b675f7c9 /Lib/test/test_asyncio/test_proactor_events.py | |
parent | 92f9339a58a613a56683510499509d1b702921a8 (diff) | |
download | cpython-git-a10dc3efcbba8aa7cc7d1a017f8b22fc4fa8e87c.tar.gz |
asyncio: use directly socket.socketpair() (#4597)
Since Python 3.5, socket.socketpair() is also available on Windows,
and so can be used directly, rather than using
asyncio.windows_utils.socketpair().
Diffstat (limited to 'Lib/test/test_asyncio/test_proactor_events.py')
-rw-r--r-- | Lib/test/test_asyncio/test_proactor_events.py | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/Lib/test/test_asyncio/test_proactor_events.py b/Lib/test/test_asyncio/test_proactor_events.py index 7a8b52352d..def08b96ab 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) |