mirror of
https://github.com/python/cpython.git
synced 2025-08-27 04:05:34 +00:00
gh-113879: Fix ResourceWarning in test_asyncio.test_server (GH-113881)
This commit is contained in:
parent
1b7e0024a1
commit
ab0ad62038
1 changed files with 14 additions and 14 deletions
|
@ -200,13 +200,13 @@ class UnixServerCleanupTests(unittest.IsolatedAsyncioTestCase):
|
||||||
async def serve(*args):
|
async def serve(*args):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:
|
||||||
sock.bind(addr)
|
sock.bind(addr)
|
||||||
|
|
||||||
srv = await asyncio.start_unix_server(serve, sock=sock)
|
srv = await asyncio.start_unix_server(serve, sock=sock)
|
||||||
|
|
||||||
srv.close()
|
srv.close()
|
||||||
self.assertFalse(os.path.exists(addr))
|
self.assertFalse(os.path.exists(addr))
|
||||||
|
|
||||||
@socket_helper.skip_unless_bind_unix_socket
|
@socket_helper.skip_unless_bind_unix_socket
|
||||||
async def test_unix_server_cleanup_gone(self):
|
async def test_unix_server_cleanup_gone(self):
|
||||||
|
@ -215,14 +215,14 @@ class UnixServerCleanupTests(unittest.IsolatedAsyncioTestCase):
|
||||||
async def serve(*args):
|
async def serve(*args):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:
|
||||||
sock.bind(addr)
|
sock.bind(addr)
|
||||||
|
|
||||||
srv = await asyncio.start_unix_server(serve, sock=sock)
|
srv = await asyncio.start_unix_server(serve, sock=sock)
|
||||||
|
|
||||||
os.unlink(addr)
|
os.unlink(addr)
|
||||||
|
|
||||||
srv.close()
|
srv.close()
|
||||||
|
|
||||||
@socket_helper.skip_unless_bind_unix_socket
|
@socket_helper.skip_unless_bind_unix_socket
|
||||||
async def test_unix_server_cleanup_replaced(self):
|
async def test_unix_server_cleanup_replaced(self):
|
||||||
|
@ -234,11 +234,11 @@ class UnixServerCleanupTests(unittest.IsolatedAsyncioTestCase):
|
||||||
srv = await asyncio.start_unix_server(serve, addr)
|
srv = await asyncio.start_unix_server(serve, addr)
|
||||||
|
|
||||||
os.unlink(addr)
|
os.unlink(addr)
|
||||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:
|
||||||
sock.bind(addr)
|
sock.bind(addr)
|
||||||
|
|
||||||
srv.close()
|
srv.close()
|
||||||
self.assertTrue(os.path.exists(addr))
|
self.assertTrue(os.path.exists(addr))
|
||||||
|
|
||||||
@socket_helper.skip_unless_bind_unix_socket
|
@socket_helper.skip_unless_bind_unix_socket
|
||||||
async def test_unix_server_cleanup_prevented(self):
|
async def test_unix_server_cleanup_prevented(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue