From 1402a1ffde10ab0713290bc7215b1b5134d3a3aa Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 5 Oct 2023 16:37:13 +0200 Subject: [PATCH] gh-110391: socket NetworkConnectionAttributesTest always declare cli NetworkConnectionAttributesTest of test_socket now always declare the 'cli' attribute, so clientTearDown() cannot fail with AttributeError. --- Lib/test/test_socket.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index 99c4c5cbc4902d..09605f7e774dda 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -5356,6 +5356,7 @@ def test_create_connection_timeout(self): class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest): + cli = None def __init__(self, methodName='runTest'): SocketTCPTest.__init__(self, methodName=methodName) @@ -5365,7 +5366,8 @@ def clientSetUp(self): self.source_port = socket_helper.find_unused_port() def clientTearDown(self): - self.cli.close() + if self.cli is not None: + self.cli.close() self.cli = None ThreadableTest.clientTearDown(self)