Skip to content

Commit 4ed055e

Browse files
committed
close the client
1 parent f02a791 commit 4ed055e

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

test/asynchronous/test_encryption.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ async def test_init_kms_tls_options(self):
170170
# Error cases:
171171
opts = AutoEncryptionOpts({}, "k.d", kms_tls_options={"kmip": 1})
172172
with self.assertRaisesRegex(TypeError, r'kms_tls_options\["kmip"\] must be a dict'):
173-
AsyncMongoClient(auto_encryption_opts=opts)
173+
client = AsyncMongoClient(auto_encryption_opts=opts)
174+
await client.close()
174175

175176
tls_opts: Any
176177
for tls_opts in [
@@ -180,12 +181,14 @@ async def test_init_kms_tls_options(self):
180181
]:
181182
opts = AutoEncryptionOpts({}, "k.d", kms_tls_options=tls_opts)
182183
with self.assertRaisesRegex(ConfigurationError, "Insecure TLS options prohibited"):
183-
AsyncMongoClient(auto_encryption_opts=opts)
184+
client = AsyncMongoClient(auto_encryption_opts=opts)
185+
await client.close()
184186
opts = AutoEncryptionOpts(
185187
{}, "k.d", kms_tls_options={"kmip": {"tlsCAFile": "does-not-exist"}}
186188
)
187189
with self.assertRaises(FileNotFoundError):
188-
AsyncMongoClient(auto_encryption_opts=opts)
190+
client = AsyncMongoClient(auto_encryption_opts=opts)
191+
await client.close()
189192
# Success cases:
190193
tls_opts: Any
191194
for tls_opts in [None, {}]:

test/test_encryption.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ def test_init_kms_tls_options(self):
170170
# Error cases:
171171
opts = AutoEncryptionOpts({}, "k.d", kms_tls_options={"kmip": 1})
172172
with self.assertRaisesRegex(TypeError, r'kms_tls_options\["kmip"\] must be a dict'):
173-
MongoClient(auto_encryption_opts=opts)
173+
client = MongoClient(auto_encryption_opts=opts)
174+
client.close()
174175

175176
tls_opts: Any
176177
for tls_opts in [
@@ -180,12 +181,14 @@ def test_init_kms_tls_options(self):
180181
]:
181182
opts = AutoEncryptionOpts({}, "k.d", kms_tls_options=tls_opts)
182183
with self.assertRaisesRegex(ConfigurationError, "Insecure TLS options prohibited"):
183-
MongoClient(auto_encryption_opts=opts)
184+
client = MongoClient(auto_encryption_opts=opts)
185+
client.close()
184186
opts = AutoEncryptionOpts(
185187
{}, "k.d", kms_tls_options={"kmip": {"tlsCAFile": "does-not-exist"}}
186188
)
187189
with self.assertRaises(FileNotFoundError):
188-
MongoClient(auto_encryption_opts=opts)
190+
client = MongoClient(auto_encryption_opts=opts)
191+
client.close()
189192
# Success cases:
190193
tls_opts: Any
191194
for tls_opts in [None, {}]:

0 commit comments

Comments
 (0)