def test_hooks_are_run_even_if_there_was_an_exception(wrapper):
class Bar(object):
def will_fail(self):
assert ctx.before_call_count == 1
raise Exception('heh')
bar = Bar()
ctx = ControllableContextManager()
wrapper(
cls_to_wrap=Bar, method_to_wrap_name='will_fail', context_manager=ctx,
is_cls_method=False)
with pytest.raises(Exception) as excinfo:
bar.will_fail()
assert str(excinfo.value) == 'heh'
assert ctx.before_call_count == 1
assert ctx.after_call_count == 1
test_wrapper.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录