def _patch_thread_ident(self):
        self.ident = 1

        test_instance = self

        class MockThreadingLocal(object):
            def __init__(self):
                self.__dict__['state'] = collections.defaultdict(dict)

            def __deepcopy__(self, memo):
                return self

            def __getattr__(self, key):
                ns = self.state[test_instance.ident]
                try:
                    return ns[key]
                except __HOLE__:
                    raise AttributeError(key)

            def __setattr__(self, key, value):
                ns = self.state[test_instance.ident]
                ns[key] = value

            def __delattr__(self, key):
                ns = self.state[test_instance.ident]
                try:
                    del ns[key]
                except KeyError:
                    raise AttributeError(key)

        return mock.patch.object(
            enginefacade, "_TransactionContextTLocal", MockThreadingLocal)
dataset/ETHPy150Open openstack/oslo.db/oslo_db/tests/sqlalchemy/test_enginefacade.py/ThreadingTest._patch_thread_ident