-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
The hasattr call below seems to always pass, meaning that the new function is called even if it doesn't exist (making this a breaking change from 2.1.2 -> 2.2.0):
pytest-mongodb/pytest_mongodb/plugin.py
Lines 90 to 93 in b17fe96
| def list_collection_names(db): | |
| if hasattr(db, 'list_collection_names'): | |
| return db.list_collection_names() | |
| return db.collection_names(include_system_collections=False) |
Example (partially omitted for legibility):
>>> db
Database(MongoClient(...), 'mydb')
>>> db.collection_names(include_system_collections=False)
['mycollection', ...]
>>> hasattr(db, 'list_collection_names')
True
>>> db.list_collection_names()
TypeError: 'Collection' object is not callable.
>>> hasattr(db, 'this is a nonsense string')
TrueIntroduced with 982ad12
I suspect insert_many will have the same issue.
Metadata
Metadata
Assignees
Labels
No labels