def test_exiting_a_not_entered_context_is_an_error(self):
ctx = Context()
with pytest.raises(ValueError) as excinfo:
ctx.exit(key='no such key', value='some value')
assert str(excinfo.value) == \
'cannot exit not entered context - key {!r} mismatch'.format(
'no such key')
ctx.enter(key='key', value='enter value')
with pytest.raises(ValueError) as excinfo:
ctx.exit(key='key', value='exit value')
assert str(excinfo.value) == \
'cannot exit not entered context - value mismatch ' \
'(exit: {!r}, enter: {!r})'.format(
'exit value', 'enter value')
test_core_context.py 文件源码
python
阅读 20
收藏 0
点赞 0
评论 0
评论列表
文章目录