]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-110391: socket NetworkConnectionAttributesTest always declare cli (#110401)
authorVictor Stinner <vstinner@python.org>
Thu, 5 Oct 2023 16:31:02 +0000 (18:31 +0200)
committerGitHub <noreply@github.com>
Thu, 5 Oct 2023 16:31:02 +0000 (18:31 +0200)
NetworkConnectionAttributesTest of test_socket now always declare the
'cli' attribute, so clientTearDown() cannot fail with AttributeError.

Lib/test/test_socket.py

index 99c4c5cbc4902de4c0c222601ea80912f6478c0e..09605f7e774dda60818831440cf9311f9e81526d 100644 (file)
@@ -5356,6 +5356,7 @@ class NetworkConnectionNoServer(unittest.TestCase):
 
 
 class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest):
+    cli = None
 
     def __init__(self, methodName='runTest'):
         SocketTCPTest.__init__(self, methodName=methodName)
@@ -5365,7 +5366,8 @@ class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest):
         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)