Skip to content

Commit e011ceb

Browse files
authored
Merge pull request #505 from MongoEngine/remove_tests_warnings
Changed: Tests: treat all warnings as errors (#498)
2 parents f8fe4e6 + 96caadf commit e011ceb

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ use_parentheses = true
123123
addopts = "--cov=flask_mongoengine --cov-config=setup.cfg"
124124
testpaths = ["tests"]
125125
filterwarnings = [
126+
"error",
127+
"ignore::ResourceWarning",
126128
"ignore::DeprecationWarning:flask_mongoengine",
127129
"ignore::DeprecationWarning:tests",
128130
]

tests/test_forms_v2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33

44
import pytest
5+
from bson.json_util import RELAXED_JSON_OPTIONS
56
from werkzeug.datastructures import MultiDict
67

78
wtforms = pytest.importorskip("wtforms")
@@ -160,7 +161,7 @@ class AllFieldsModel(db.Document):
160161
form.save()
161162

162163
obj = AllFieldsModel.objects.get(id=form.instance.pk)
163-
object_dict = json.loads(obj.to_json())
164+
object_dict = json.loads(obj.to_json(json_options=RELAXED_JSON_OPTIONS))
164165
object_dict.pop("_id")
165166

166167
assert object_dict == {

tests/test_json_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def as_pymongo():
1818
@app.route("/aggregate")
1919
def aggregate():
2020
return flask.jsonify(
21-
result=Todo.objects().aggregate({"$match": {"title": {"$ne": "lksdjh"}}})
21+
result=Todo.objects().aggregate([{"$match": {"title": {"$ne": "lksdjh"}}}])
2222
)
2323

2424
@app.route("/add", methods=["POST"])

0 commit comments

Comments
 (0)