Skip to content

Commit 0e8d68f

Browse files
committed
more Windows fixups
1 parent 3ba5e47 commit 0e8d68f

2 files changed

Lines changed: 7 additions & 28 deletions

File tree

tests/python/test_windows_events.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import sys
3+
import socket
34
import unittest
45
from unittest import mock
56

@@ -38,7 +39,7 @@ def setUp(self):
3839
self.set_event_loop(self.loop)
3940

4041
def test_close(self):
41-
a, b = self.loop._socketpair()
42+
a, b = socket.socketpair()
4243
trans = self.loop._make_socket_transport(a, asyncio.Protocol())
4344
f = asyncio.ensure_future(self.loop.sock_recv(b, 100))
4445
trans.close()

tests/python/test_windows_utils.py

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,40 +30,18 @@ def check_winsocketpair(self, ssock, csock):
3030
ssock.close()
3131

3232
def test_winsocketpair(self):
33-
ssock, csock = windows_utils.socketpair()
33+
ssock, csock = socket.socketpair()
3434
self.check_winsocketpair(ssock, csock)
3535

3636
@unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 not supported or enabled')
3737
def test_winsocketpair_ipv6(self):
38-
ssock, csock = windows_utils.socketpair(family=socket.AF_INET6)
38+
ssock, csock = socket.socketpair(family=socket.AF_INET6)
3939
self.check_winsocketpair(ssock, csock)
4040

41-
@unittest.skipIf(hasattr(socket, 'socketpair'), 'socket.socketpair is available')
42-
@mock.patch('asyncio.windows_utils.socket')
43-
def test_winsocketpair_exc(self, m_socket):
44-
m_socket.AF_INET = socket.AF_INET
45-
m_socket.SOCK_STREAM = socket.SOCK_STREAM
46-
m_socket.socket.return_value.getsockname.return_value = ('', 12345)
47-
m_socket.socket.return_value.accept.return_value = object(), object()
48-
m_socket.socket.return_value.connect.side_effect = OSError()
49-
50-
self.assertRaises(OSError, windows_utils.socketpair)
51-
5241
def test_winsocketpair_invalid_args(self):
53-
self.assertRaises(ValueError, windows_utils.socketpair, family=socket.AF_UNSPEC)
54-
self.assertRaises(ValueError, windows_utils.socketpair, type=socket.SOCK_DGRAM)
55-
self.assertRaises(ValueError, windows_utils.socketpair, proto=1)
56-
57-
@unittest.skipIf(hasattr(socket, 'socketpair'), 'socket.socketpair is available')
58-
@mock.patch('asyncio.windows_utils.socket')
59-
def test_winsocketpair_close(self, m_socket):
60-
m_socket.AF_INET = socket.AF_INET
61-
m_socket.SOCK_STREAM = socket.SOCK_STREAM
62-
sock = mock.Mock()
63-
m_socket.socket.return_value = sock
64-
sock.bind.side_effect = OSError
65-
self.assertRaises(OSError, windows_utils.socketpair)
66-
self.assertTrue(sock.close.called)
42+
self.assertRaises(ValueError, socket.socketpair, family=socket.AF_UNSPEC)
43+
self.assertRaises(ValueError, socket.socketpair, type=socket.SOCK_DGRAM)
44+
self.assertRaises(ValueError, socket.socketpair, proto=1)
6745

6846

6947
class PipeTests(unittest.TestCase):

0 commit comments

Comments
 (0)