Skip to content

unit test DeprecationWarning #668

Closed
Closed

Description

@engFelipeMonteiro

the unit test of this repository is using osolete method, in soon version it might stop working

tests/test__mongomock.py::InsertedDocumentTest::test__remove_by_id
 ./mongomock/tests/test__mongomock.py:3649: DeprecationWarning: remove is deprecated. Use delete_one or delete_many instead.
    self.collection.remove(self.object_id)

tests/test__mongomock.py::InsertedDocumentTest::test__remove_by_id
 ./tests/test__mongomock.py:3650: DeprecationWarning: count is deprecated. Use estimated_document_count or count_documents instead. Please note that $where must be replaced by $expr, $near must be replaced by $geoWithin with $center, and $nearSphere must be replaced by $geoWithin with $centerSphere
    self.assertEqual(0, self.collection.count())

tests/test__mongomock.py::DatabasesNamesTest::test__database_names
  ./mongomock/tests/test__mongomock.py:3690: DeprecationWarning: insert is deprecated. Use insert_one or insert_many instead.
    self.client.unit.tests.insert({'foo': 'bar'})

tests/test__mongomock.py::DatabasesNamesTest::test__database_names
  ./mongomock/tests/test__mongomock.py:3691: DeprecationWarning: insert is deprecated. Use insert_one or insert_many instead.
    self.client.foo.bar.insert({'unit': 'test'})

tests/test__mongomock.py::DatabasesNamesTest::test__database_names
tests/test__patch.py::PatchTest::test__decorator
 ./mongomock/mongomock/mongo_client.py:112: UserWarning: database_names is deprecated. Use list_database_names instead.
    warnings.warn('database_names is deprecated. Use list_database_names instead.')


Activity

  1. self-assigned this
    on Oct 3, 2020
  2. pcorpet commented on Oct 3, 2020

    @pcorpet
    Member

    Note that we want to keep some of them as we want to copy pymongo behavior. Once pymongo removes them we will stop using and testing them.

    However for now those are used in many places even when they are not tested so I'll clean it up a bit.

  3. added a commit that references this issue on Oct 3, 2020
    edc0760
  4. ankostis commented on Mar 23, 2023

    @ankostis

    But does estimated_document_count() collection-method work?

  5. ankostis commented on Mar 23, 2023

    @ankostis

    Indeed it works. Forgive my eventual spam.

  6. added a commit that references this issue on May 26, 2025
    b26e7b3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions