@@ -576,6 +576,7 @@ def test_mongodb_x509_auth(self):
576576 ssl = True ,
577577 ssl_cert_reqs = ssl .CERT_NONE ,
578578 ssl_certfile = CLIENT_PEM )
579+ self .addCleanup (noauth .close )
579580
580581 self .assertRaises (OperationFailure , noauth .pymongo_test .test .count )
581582
@@ -587,6 +588,7 @@ def test_mongodb_x509_auth(self):
587588 ssl_cert_reqs = ssl .CERT_NONE ,
588589 ssl_certfile = CLIENT_PEM ,
589590 event_listeners = [listener ])
591+ self .addCleanup (auth .close )
590592
591593 if client_context .version .at_least (3 , 3 , 12 ):
592594 # No error
@@ -609,6 +611,7 @@ def test_mongodb_x509_auth(self):
609611 ssl = True ,
610612 ssl_cert_reqs = ssl .CERT_NONE ,
611613 ssl_certfile = CLIENT_PEM )
614+ self .addCleanup (client .close )
612615 # No error
613616 client .pymongo_test .test .find_one ()
614617
@@ -617,6 +620,7 @@ def test_mongodb_x509_auth(self):
617620 ssl = True ,
618621 ssl_cert_reqs = ssl .CERT_NONE ,
619622 ssl_certfile = CLIENT_PEM )
623+ self .addCleanup (client .close )
620624 if client_context .version .at_least (3 , 3 , 12 ):
621625 # No error
622626 client .pymongo_test .test .find_one ()
@@ -625,13 +629,16 @@ def test_mongodb_x509_auth(self):
625629 with self .assertRaises (ConfigurationError ):
626630 client .pymongo_test .test .find_one ()
627631
632+ # No error
633+ client .pymongo_test .test .find_one ()
628634 # Auth should fail if username and certificate do not match
629635 uri = ('mongodb://%s@%s:%d/?authMechanism='
630636 'MONGODB-X509' % (
631637 quote_plus ("not the username" ), host , port ))
632638
633639 bad_client = MongoClient (
634640 uri , ssl = True , ssl_cert_reqs = "CERT_NONE" , ssl_certfile = CLIENT_PEM )
641+ self .addCleanup (bad_client .close )
635642
636643 with self .assertRaises (OperationFailure ):
637644 bad_client .pymongo_test .test .find_one ()
@@ -643,6 +650,7 @@ def test_mongodb_x509_auth(self):
643650 ssl = True ,
644651 ssl_cert_reqs = ssl .CERT_NONE ,
645652 ssl_certfile = CLIENT_PEM )
653+ self .addCleanup (bad_client .close )
646654
647655 with self .assertRaises (OperationFailure ):
648656 bad_client .pymongo_test .test .find_one ()
0 commit comments