def __enter__(self):
        try:
            self.orig_database = _override_db.class_to_db[self.document_class]
        except __HOLE__:
            self.orig_get_db = self.document_class.get_db
            self.document_class.get_db = classmethod(_get_db)
        _override_db.class_to_db[self.document_class] = self.database
dataset/ETHPy150Open dimagi/commcare-hq/corehq/util/couch_helpers.py/OverrideDB.__enter__