diff --git a/HISTORY.rst b/HISTORY.rst index 3d66511..9ee4ae6 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,6 +2,15 @@ History ======= +3.2.0 (2024-04-30) +------------------ + +Features: + +* Add compatibility with `pymongo` 4.0. +* Allow `motor` 4.0 dependency so that `pymongo` 4.x dependency can be used. + + 3.1.0 (2021-12-23) ------------------ diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 223868e..725976c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -25,7 +25,8 @@ stages: parameters: toxenvs: - py39-pymongo - - py39-motor + - py39-motor2 + - py39-motor3 - py39-txmongo coverage: true pre_test: @@ -44,10 +45,12 @@ stages: parameters: toxenvs: - py37-pymongo - - py37-motor + - py37-motor2 + - py37-motor3 - py37-txmongo - py39-pymongo - - py39-motor + - py39-motor2 + - py39-motor3 - py39-txmongo coverage: true pre_test: diff --git a/setup.py b/setup.py index aa5b05c..1aab81c 100755 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ python_requires='>=3.7', install_requires=requirements, extras_require={ - 'motor': ['motor>=2.0,<3.0'], + 'motor': ['motor>=2.0,<4.0'], 'txmongo': ['txmongo>=19.2.0'], 'mongomock': ['mongomock'], }, diff --git a/tests/common.py b/tests/common.py index 047143b..7e598d1 100644 --- a/tests/common.py +++ b/tests/common.py @@ -71,13 +71,13 @@ def is_compatible_with(db): class BaseTest: - def setup(self): + def setup_method(self): self.instance = MockedInstance(MockedDB('my_moked_db')) class BaseDBTest: - def setup(self): + def setup_method(self): con.drop_database(TEST_DB) diff --git a/tests/frameworks/test_txmongo.py b/tests/frameworks/test_txmongo.py index 98c4b04..74eea77 100644 --- a/tests/frameworks/test_txmongo.py +++ b/tests/frameworks/test_txmongo.py @@ -289,9 +289,9 @@ def test_reference(self, classroom_model): assert teacher_fetched.name == 'Dr. Brown' teacher_fetched = yield course.teacher.fetch(force_reload=True) assert teacher_fetched.name == 'M. Strickland' - # Test fetch with projection - assert course.teacher.fetch(projection={'has_apple': 0}, - force_reload=True).has_apple is None + # Test fetch with projection, without `yield`. + teacher_fetched = course.teacher.fetch(projection={'has_apple': 0}, force_reload=True) + assert isinstance(teacher_fetched, Deferred) # Test bad ref as well course.teacher = Reference(classroom_model.Teacher, ObjectId()) with pytest.raises(ma.ValidationError) as exc: diff --git a/tests/test_document.py b/tests/test_document.py index fb268a9..c786c87 100644 --- a/tests/test_document.py +++ b/tests/test_document.py @@ -36,8 +36,8 @@ class Meta: class TestDocument(BaseTest): - def setup(self): - super().setup() + def setup_method(self): + super().setup_method() self.instance.register(BaseStudent) self.Student = self.instance.register(Student) self.EasyIdStudent = self.instance.register(EasyIdStudent) diff --git a/tests/test_embedded_document.py b/tests/test_embedded_document.py index 5323c0f..59edc37 100644 --- a/tests/test_embedded_document.py +++ b/tests/test_embedded_document.py @@ -60,7 +60,7 @@ class MyDoc(Document): d.from_mongo(data={'in_mongo_embedded': {'in_mongo_a': 1, 'b': 2}}) assert d.dump() == {'embedded': {'a': 1, 'b': 2}} embedded = d.get('embedded') - assert type(embedded) == MyEmbeddedDocument + assert type(embedded) is MyEmbeddedDocument assert embedded.a == 1 assert embedded.b == 2 assert embedded.dump() == {'a': 1, 'b': 2} diff --git a/tests/test_marshmallow.py b/tests/test_marshmallow.py index c3748b6..4bf6730 100644 --- a/tests/test_marshmallow.py +++ b/tests/test_marshmallow.py @@ -21,8 +21,8 @@ def teardown_method(self, method): # Reset i18n config before each test set_gettext(None) - def setup(self): - super().setup() + def setup_method(self): + super().setup_method() class User(Document): name = fields.StrField() diff --git a/tox.ini b/tox.ini index 1e2248a..2f4f9cb 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = lint,{py37,py38,py39}-{motor,pymongo,txmongo} +envlist = lint,{py37,py38,py39}-{motor2,motor3,pymongo3,pymongo4,txmongo} [testenv] setenv = @@ -7,8 +7,12 @@ setenv = deps = pytest>=4.0.0 coverage>=5.3.0 - motor: motor>=2.0,<3.0 - pymongo: mongomock>=3.5.0 + motor2: motor>=2.0,<3.0 + motor3: motor>=3.0,<4.0 + pymongo3: pymongo>3,<4 + pymongo3: mongomock>=3.5.0 + pymongo4: pymongo>4,<5 + pymongo4: mongomock>=3.5.0 txmongo: pymongo<3.11 txmongo: txmongo>=19.2.0 txmongo: pytest-twisted>=1.12