]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-110391: socket NetworkConnectionAttributesTest always declare cli (GH-11040...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 5 Oct 2023 17:01:59 +0000 (10:01 -0700)
committerGitHub <noreply@github.com>
Thu, 5 Oct 2023 17:01:59 +0000 (17:01 +0000)
gh-110391: socket NetworkConnectionAttributesTest always declare cli (GH-110401)

NetworkConnectionAttributesTest of test_socket now always declare the
'cli' attribute, so clientTearDown() cannot fail with AttributeError.
(cherry picked from commit e37d4557c3de0476e76ca4b8a1cc8d2566b86c79)

Co-authored-by: Victor Stinner <vstinner@python.org>
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)