gh-113879: Fix ResourceWarning in test_asyncio.test_server (GH-113881)

This commit is contained in:
Serhiy Storchaka 2024-01-10 12:38:36 +02:00 committed by GitHub
parent 1b7e0024a1
commit ab0ad62038
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -200,7 +200,7 @@ class UnixServerCleanupTests(unittest.IsolatedAsyncioTestCase):
async def serve(*args):
pass
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:
sock.bind(addr)
srv = await asyncio.start_unix_server(serve, sock=sock)
@ -215,7 +215,7 @@ class UnixServerCleanupTests(unittest.IsolatedAsyncioTestCase):
async def serve(*args):
pass
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:
sock.bind(addr)
srv = await asyncio.start_unix_server(serve, sock=sock)
@ -234,7 +234,7 @@ class UnixServerCleanupTests(unittest.IsolatedAsyncioTestCase):
srv = await asyncio.start_unix_server(serve, 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)
srv.close()