You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using mock library version 4+, or unittest.mock on newer versions of Python, patching a TG global like tg.request etc will error out if you don't have any global context objects set up. This is unexpected since the goal of patching an object is so that it isn't used at all.
Traceback (most recent call last):
File "/tmp-venv/lib/python3.7/site-packages/mock/mock.py", line 1422, in patched
keywargs) as (newargs, newkeywargs):
File "/usr/local/lib/python3.7/contextlib.py", line 112, in __enter__returnnext(self.gen)
File "/tmp-venv/lib/python3.7/site-packages/mock/mock.py", line 1402, in decoration_helper
arg = exit_stack.enter_context(patching)
File "/usr/local/lib/python3.7/contextlib.py", line 427, in enter_context
result = _cm_type.__enter__(cm)
File "/tmp-venv/lib/python3.7/site-packages/mock/mock.py", line 1514, in __enter__if spec isNoneand _is_async_obj(original):
File "/tmp-venv/lib/python3.7/site-packages/mock/mock.py", line 61, in _is_async_objreturn iscoroutinefunction(obj) or inspect.isawaitable(obj)
File "/tmp-venv/lib/python3.7/site-packages/mock/backports.py", line 34, in iscoroutinefunctiongetattr(obj, '_is_coroutine', None) is _is_coroutine
File "/tmp-venv/lib/python3.7/site-packages/tg/support/objectproxy.py", line 26, in __getattr__returngetattr(self._current_obj(), attr)
File "/tmp-venv/lib/python3.7/site-packages/tg/request_local.py", line 235, in _current_objreturngetattr(context, self.name)
File "/tmp-venv/lib/python3.7/site-packages/tg/support/objectproxy.py", line 26, in __getattr__returngetattr(self._current_obj(), attr)
File "/tmp-venv/lib/python3.7/site-packages/tg/support/registry.py", line 72, in _current_obj'thread'%self.____name__)
TypeError: No object (name: context) has been registered for this thread
I'll submit a merge request with a potential fix.
The text was updated successfully, but these errors were encountered:
When using
mock
library version 4+, orunittest.mock
on newer versions of Python, patching a TG global liketg.request
etc will error out if you don't have any global context objects set up. This is unexpected since the goal of patching an object is so that it isn't used at all.causes this error:
I'll submit a merge request with a potential fix.
The text was updated successfully, but these errors were encountered: