diff --git a/docs/guide/mongomock.rst b/docs/guide/mongomock.rst
index d70ee6a6..040ff912 100644
--- a/docs/guide/mongomock.rst
+++ b/docs/guide/mongomock.rst
@@ -2,10 +2,10 @@
Use mongomock for testing
==============================
-`mongomock `_ is a package to do just
+`mongomock `_ is a package to do just
what the name implies, mocking a mongo database.
-To use with mongoengine, simply specify mongomock when connecting with
+To use with mongoengine, simply specify mongomock when connecting with
mongoengine:
.. code-block:: python
@@ -45,4 +45,4 @@ Example of test file:
pers.save()
fresh_pers = Person.objects().first()
- self.assertEqual(fresh_pers.name, 'John')
+ assert fresh_pers.name == 'John'
diff --git a/tests/document/test_instance.py b/tests/document/test_instance.py
index b899684f..609d0690 100644
--- a/tests/document/test_instance.py
+++ b/tests/document/test_instance.py
@@ -3338,19 +3338,19 @@ class TestInstance(MongoDBTestCase):
# worker1.job should be equal to the job used originally to create the
# document.
- self.assertEqual(worker1.job, worker.job)
+ assert worker1.job == worker.job
# worker1.job should be equal to a newly created Job EmbeddedDocument
# using either the Boss object or his ID.
- self.assertEqual(worker1.job, Job(boss=boss, boss_dbref=boss))
- self.assertEqual(worker1.job, Job(boss=boss.id, boss_dbref=boss.id))
+ assert worker1.job == Job(boss=boss, boss_dbref=boss)
+ assert worker1.job == Job(boss=boss.id, boss_dbref=boss.id)
# The above equalities should also hold after worker1.job.boss has been
# fetch()ed.
worker1.job.boss.fetch()
- self.assertEqual(worker1.job, worker.job)
- self.assertEqual(worker1.job, Job(boss=boss, boss_dbref=boss))
- self.assertEqual(worker1.job, Job(boss=boss.id, boss_dbref=boss.id))
+ assert worker1.job == worker.job
+ assert worker1.job == Job(boss=boss, boss_dbref=boss)
+ assert worker1.job == Job(boss=boss.id, boss_dbref=boss.id)
def test_dbref_equality(self):
class Test2(Document):
@@ -3693,13 +3693,13 @@ class TestInstance(MongoDBTestCase):
value = u"I_should_be_a_dict"
coll.insert_one({"light_saber": value})
- with self.assertRaises(InvalidDocumentError) as cm:
+ with pytest.raises(InvalidDocumentError) as exc_info:
list(Jedi.objects)
- self.assertEqual(
- str(cm.exception),
- "Invalid data to create a `Jedi` instance.\nField 'light_saber' - The source SON object needs to be of type 'dict' but a '%s' was found"
- % type(value),
+ assert str(
+ exc_info.value
+ ) == "Invalid data to create a `Jedi` instance.\nField 'light_saber' - The source SON object needs to be of type 'dict' but a '%s' was found" % type(
+ value
)
diff --git a/tests/fields/test_file_field.py b/tests/fields/test_file_field.py
index bfc86511..b8ece1a9 100644
--- a/tests/fields/test_file_field.py
+++ b/tests/fields/test_file_field.py
@@ -151,7 +151,7 @@ class TestFileField(MongoDBTestCase):
result = StreamFile.objects.first()
assert streamfile == result
assert result.the_file.read() == text + more_text
- # self.assertEqual(result.the_file.content_type, content_type)
+ # assert result.the_file.content_type == content_type
result.the_file.seek(0)
assert result.the_file.tell() == 0
assert result.the_file.read(len(text)) == text