MCPcopy
hub / github.com/celery/celery / _mock_context

Function _mock_context

t/unit/conftest.py:701–714  ·  view source on GitHub ↗
(mock)

Source from the content-addressed store, hash-verified

699
700@contextmanager
701def _mock_context(mock):
702 context = mock.return_value = Mock()
703 context.__enter__ = Mock()
704 context.__exit__ = Mock()
705
706 def on_exit(*x):
707 if x[0]:
708 raise x[0] from x[1]
709 context.__exit__.side_effect = on_exit
710 context.__enter__.return_value = context
711 try:
712 yield context
713 finally:
714 context.reset()
715
716
717@contextmanager

Callers 1

openFunction · 0.85

Calls 1

resetMethod · 0.45

Tested by

no test coverage detected