def _post_teardown(self): super(MongoTestCase, self)._post_teardown() for collection in self.database.collection_names(): if collection == 'system.indexes': continue self.database.drop_collection(collection) # Mongoengine models need to forget about their collection (to recreate indexes). Hackish, I know. # pylint: disable=E1101 for model in Document.__subclasses__(): if hasattr(model, '_collection'): del model._collection disconnect()
def _post_teardown(self): for collection in self._database.collection_names(): if collection == 'system.indexes': # pragma: no cover continue self._database.drop_collection(collection) # Mongoengine models need to forget about their collection (to recreate indexes). Hackish, I know. # FIXME: __subclasses__ may only take direct descendants into account! for model in Document.__subclasses__(): if hasattr(model, '_collection'): del model._collection disconnect() super(MongoTestCase, self)._post_teardown()
def reset_connection_cache(): connection._connections = {} connection._connection_settings = {} connection._dbs = {} for document_class in Document.__subclasses__(): document_class._collection = None
def _clear_db(self, config): for model in Document.__subclasses__(): if model == DynamicDocument: continue model.drop_collection()