Skip to content

Commit

Permalink
fix task teardown
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Jan 15, 2025
1 parent f72727c commit 5b49ba5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ def test_config_with_uri_in_flask_conf_var(self):
mongo = flask_pymongo.PyMongo(self.app, connect=True)

_wait_until_connected(mongo)
assert mongo.db is not None
assert mongo.cx is not None
self.addCleanup(mongo.cx.close)
assert mongo.db is not None
assert mongo.db.name == self.dbname
assert ("localhost", self.port) == mongo.cx.address or (
"127.0.0.1",
Expand All @@ -62,8 +63,9 @@ def test_config_with_uri_passed_directly(self):
mongo = flask_pymongo.PyMongo(self.app, uri, connect=True)

_wait_until_connected(mongo)
assert mongo.db is not None
assert mongo.cx is not None
self.addCleanup(mongo.cx.close)
assert mongo.db is not None
assert mongo.db.name == self.dbname
assert ("localhost", self.port) == mongo.cx.address or (
"127.0.0.1",
Expand Down Expand Up @@ -91,6 +93,8 @@ class CustomDict(dict[str, Any]):

uri = f"mongodb://localhost:{self.port}/{self.dbname}"
mongo = flask_pymongo.PyMongo(self.app, uri, document_class=CustomDict)
assert mongo.cx is not None
self.addCleanup(mongo.cx.close)
assert mongo.db is not None
assert mongo.db.things.find_one() is None, "precondition failed"

Expand Down

0 comments on commit 5b49ba5

Please sign in to comment.