def test_three_managers_middle_one_fails(self):
""" this is like raising the LimitViolationError """
ControllableContextManager.reset_events()
outer = ControllableContextManager()
middle = ControllableContextManager(fail_in_method='__exit__')
inner = ControllableContextManager()
ControllableContextManager.reset_events()
with pytest.raises(ControllableContextManager.TestException):
with outer:
with middle:
with inner:
pass
expected_calls = self.get_recorded_calls()
assert expected_calls == [
(outer, '__enter__'), (middle, '__enter__'), (inner, '__enter__'),
(inner, '__exit__'), (middle, '__exit__'), (outer, '__exit__')
]
ControllableContextManager.reset_events()
with pytest.raises(ControllableContextManager.TestException):
with multi_context_manager([outer, middle, inner]):
pass
assert expected_calls == self.get_recorded_calls()
test_wrapper.py 文件源码
python
阅读 32
收藏 0
点赞 0
评论 0
评论列表
文章目录