summaryrefslogtreecommitdiff
path: root/Lib/test
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-11-28 21:33:20 +0100
committerGitHub <noreply@github.com>2017-11-28 21:33:20 +0100
commitac577d7d0bd27a69921ced14c09172235ceebab5 (patch)
tree0d8e39b6dbab0cd260764fa8acaf0390a8c509b6 /Lib/test
parent4d193bcc2560b824389e4d98d9d8b9b34e33dbaf (diff)
downloadcpython-git-ac577d7d0bd27a69921ced14c09172235ceebab5.tar.gz
bpo-32154: Remove asyncio.windows_utils.socketpair (#4609)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_asyncio/test_events.py12
-rw-r--r--Lib/test/test_asyncio/test_windows_utils.py50
2 files changed, 6 insertions, 56 deletions
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index c252a4c01e..a6941aa4a6 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -363,7 +363,7 @@ class EventLoopTestsMixin:
self.assertNotEqual(thread_id, threading.get_ident())
def test_reader_callback(self):
- r, w = test_utils.socketpair()
+ r, w = socket.socketpair()
r.setblocking(False)
bytes_read = bytearray()
@@ -391,7 +391,7 @@ class EventLoopTestsMixin:
self.assertEqual(bytes_read, b'abcdef')
def test_writer_callback(self):
- r, w = test_utils.socketpair()
+ r, w = socket.socketpair()
w.setblocking(False)
def writer(data):
@@ -1568,7 +1568,7 @@ class EventLoopTestsMixin:
@unittest.skipUnless(sys.platform != 'win32',
"Don't support pipes for Windows")
def test_write_pipe_disconnect_on_close(self):
- rsock, wsock = test_utils.socketpair()
+ rsock, wsock = socket.socketpair()
rsock.setblocking(False)
pipeobj = io.open(wsock.detach(), 'wb', 1024)
@@ -1706,7 +1706,7 @@ class EventLoopTestsMixin:
self.assertEqual('CLOSED', write_proto.state)
def test_prompt_cancellation(self):
- r, w = test_utils.socketpair()
+ r, w = socket.socketpair()
r.setblocking(False)
f = self.loop.sock_recv(r, 1)
ov = getattr(f, 'ov', None)
@@ -1771,7 +1771,7 @@ class EventLoopTestsMixin:
def test_remove_fds_after_closing(self):
loop = self.create_event_loop()
callback = lambda: None
- r, w = test_utils.socketpair()
+ r, w = socket.socketpair()
self.addCleanup(r.close)
self.addCleanup(w.close)
loop.add_reader(r, callback)
@@ -1783,7 +1783,7 @@ class EventLoopTestsMixin:
def test_add_fds_after_closing(self):
loop = self.create_event_loop()
callback = lambda: None
- r, w = test_utils.socketpair()
+ r, w = socket.socketpair()
self.addCleanup(r.close)
self.addCleanup(w.close)
loop.close()
diff --git a/Lib/test/test_asyncio/test_windows_utils.py b/Lib/test/test_asyncio/test_windows_utils.py
index 4fddaa2589..952f95e573 100644
--- a/Lib/test/test_asyncio/test_windows_utils.py
+++ b/Lib/test/test_asyncio/test_windows_utils.py
@@ -19,56 +19,6 @@ except ImportError:
from asyncio import test_support as support
-class WinsocketpairTests(unittest.TestCase):
-
- def check_winsocketpair(self, ssock, csock):
- csock.send(b'xxx')
- self.assertEqual(b'xxx', ssock.recv(1024))
- csock.close()
- ssock.close()
-
- def test_winsocketpair(self):
- ssock, csock = windows_utils.socketpair()
- self.check_winsocketpair(ssock, csock)
-
- @unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 not supported or enabled')
- def test_winsocketpair_ipv6(self):
- ssock, csock = windows_utils.socketpair(family=socket.AF_INET6)
- self.check_winsocketpair(ssock, csock)
-
- @unittest.skipIf(hasattr(socket, 'socketpair'),
- 'socket.socketpair is available')
- @mock.patch('asyncio.windows_utils.socket')
- def test_winsocketpair_exc(self, m_socket):
- m_socket.AF_INET = socket.AF_INET
- m_socket.SOCK_STREAM = socket.SOCK_STREAM
- m_socket.socket.return_value.getsockname.return_value = ('', 12345)
- m_socket.socket.return_value.accept.return_value = object(), object()
- m_socket.socket.return_value.connect.side_effect = OSError()
-
- self.assertRaises(OSError, windows_utils.socketpair)
-
- def test_winsocketpair_invalid_args(self):
- self.assertRaises(ValueError,
- windows_utils.socketpair, family=socket.AF_UNSPEC)
- self.assertRaises(ValueError,
- windows_utils.socketpair, type=socket.SOCK_DGRAM)
- self.assertRaises(ValueError,
- windows_utils.socketpair, proto=1)
-
- @unittest.skipIf(hasattr(socket, 'socketpair'),
- 'socket.socketpair is available')
- @mock.patch('asyncio.windows_utils.socket')
- def test_winsocketpair_close(self, m_socket):
- m_socket.AF_INET = socket.AF_INET
- m_socket.SOCK_STREAM = socket.SOCK_STREAM
- sock = mock.Mock()
- m_socket.socket.return_value = sock
- sock.bind.side_effect = OSError
- self.assertRaises(OSError, windows_utils.socketpair)
- self.assertTrue(sock.close.called)
-
-
class PipeTests(unittest.TestCase):
def test_pipe_overlapped(self):