Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: Upgrade motor and add pymongo 4.x to test matrix #387

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
------------------

Expand Down
9 changes: 6 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ stages:
parameters:
toxenvs:
- py39-pymongo
- py39-motor
- py39-motor2
- py39-motor3
- py39-txmongo
coverage: true
pre_test:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
alexandervaneck marked this conversation as resolved.
Show resolved Hide resolved
'txmongo': ['txmongo>=19.2.0'],
'mongomock': ['mongomock'],
},
Expand Down
4 changes: 2 additions & 2 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
6 changes: 3 additions & 3 deletions tests/frameworks/test_txmongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_embedded_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions tests/test_marshmallow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 7 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
[tox]
envlist = lint,{py37,py38,py39}-{motor,pymongo,txmongo}
envlist = lint,{py37,py38,py39}-{motor2,motor3,pymongo3,pymongo4,txmongo}

[testenv]
setenv =
PYTHONPATH = {toxinidir}:{toxinidir}/umongo
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
Expand Down