summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_streams.py
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2019-04-08 22:34:02 (GMT)
committerGitHub <noreply@github.com>2019-04-08 22:34:02 (GMT)
commiteb7e29f2a9d075accc1ab3faf3612ac44f5e2183 (patch)
tree6d4d31556465bc34e12de0ebc98dd751cb0fc09a /Lib/test/test_asyncio/test_streams.py
parent58721a903074d28151d008d8990c98fc31d1e798 (diff)
downloadcpython-eb7e29f2a9d075accc1ab3faf3612ac44f5e2183.zip
cpython-eb7e29f2a9d075accc1ab3faf3612ac44f5e2183.tar.gz
cpython-eb7e29f2a9d075accc1ab3faf3612ac44f5e2183.tar.bz2
bpo-35934: Add socket.create_server() utility function (GH-11784)
Diffstat (limited to 'Lib/test/test_asyncio/test_streams.py')
-rw-r--r--Lib/test/test_asyncio/test_streams.py11
1 files changed, 3 insertions, 8 deletions
diff --git a/Lib/test/test_asyncio/test_streams.py b/Lib/test/test_asyncio/test_streams.py
index 043fac7..630f91d 100644
--- a/Lib/test/test_asyncio/test_streams.py
+++ b/Lib/test/test_asyncio/test_streams.py
@@ -592,8 +592,7 @@ class StreamTests(test_utils.TestCase):
await client_writer.wait_closed()
def start(self):
- sock = socket.socket()
- sock.bind(('127.0.0.1', 0))
+ sock = socket.create_server(('127.0.0.1', 0))
self.server = self.loop.run_until_complete(
asyncio.start_server(self.handle_client,
sock=sock,
@@ -605,8 +604,7 @@ class StreamTests(test_utils.TestCase):
client_writer))
def start_callback(self):
- sock = socket.socket()
- sock.bind(('127.0.0.1', 0))
+ sock = socket.create_server(('127.0.0.1', 0))
addr = sock.getsockname()
sock.close()
self.server = self.loop.run_until_complete(
@@ -796,10 +794,7 @@ os.close(fd)
def server():
# Runs in a separate thread.
- sock = socket.socket()
- with sock:
- sock.bind(('localhost', 0))
- sock.listen(1)
+ with socket.create_server(('localhost', 0)) as sock:
addr = sock.getsockname()
q.put(addr)
clt, _ = sock.accept()