def drop_collection(collection_name):
    """Decorator that drops a collection from the database before and after running a test."""

    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            db = foo.get_db_conn()
            db.drop_collection(collection_name)
            try:
                return func(*args, **kwargs)
            finally:
                db.drop_collection(collection_name)

        return wrapper

    return decorator
Decorator that drops a collection from the database before and after running a test.
tests/unittests/execution_cache/decorators.py