diff --git a/test/asynchronous/test_collection.py b/test/asynchronous/test_collection.py index 6a85b63960..90a0518532 100644 --- a/test/asynchronous/test_collection.py +++ b/test/asynchronous/test_collection.py @@ -1319,7 +1319,7 @@ async def test_error_code(self): self.assertIn(exc.code, (9, 10147, 16840, 17009)) # Just check that we set the error document. Fields # vary by MongoDB version. - self.assertTrue(exc.details is not None) + self.assertIsNotNone(exc.details) else: self.fail("OperationFailure was not raised") diff --git a/test/asynchronous/test_session.py b/test/asynchronous/test_session.py index 5ed3597751..19ce868c56 100644 --- a/test/asynchronous/test_session.py +++ b/test/asynchronous/test_session.py @@ -378,9 +378,9 @@ async def test_cursor_clone(self): async with self.client.start_session() as s: cursor = coll.find(session=s) - self.assertTrue(cursor.session is s) + self.assertIs(cursor.session, s) clone = cursor.clone() - self.assertTrue(clone.session is s) + self.assertIs(clone.session, s) # No explicit session. cursor = coll.find(batch_size=2) @@ -392,7 +392,7 @@ async def test_cursor_clone(self): await anext(clone) self.assertIsNone(clone.session) self.assertIsNotNone(clone._session) - self.assertFalse(cursor._session is clone._session) + self.assertIsNot(cursor._session, clone._session) await cursor.close() await clone.close() diff --git a/test/test_collection.py b/test/test_collection.py index 0dce88423b..b1947259ba 100644 --- a/test/test_collection.py +++ b/test/test_collection.py @@ -1305,7 +1305,7 @@ def test_error_code(self): self.assertIn(exc.code, (9, 10147, 16840, 17009)) # Just check that we set the error document. Fields # vary by MongoDB version. - self.assertTrue(exc.details is not None) + self.assertIsNotNone(exc.details) else: self.fail("OperationFailure was not raised") diff --git a/test/test_session.py b/test/test_session.py index 16a219ae52..40d0a53afb 100644 --- a/test/test_session.py +++ b/test/test_session.py @@ -378,9 +378,9 @@ def test_cursor_clone(self): with self.client.start_session() as s: cursor = coll.find(session=s) - self.assertTrue(cursor.session is s) + self.assertIs(cursor.session, s) clone = cursor.clone() - self.assertTrue(clone.session is s) + self.assertIs(clone.session, s) # No explicit session. cursor = coll.find(batch_size=2) @@ -392,7 +392,7 @@ def test_cursor_clone(self): next(clone) self.assertIsNone(clone.session) self.assertIsNotNone(clone._session) - self.assertFalse(cursor._session is clone._session) + self.assertIsNot(cursor._session, clone._session) cursor.close() clone.close()