pytest.raises(UndefinedError, t.render, test=test)
def test_undefined_and_special_attributes(self):
- try:
+ with pytest.raises(AttributeError):
Undefined('Foo').__dict__
- except AttributeError:
- pass
- else:
- assert False, "Expected actual attribute error"
def test_logging_undefined(self):
_messages = []
assert t.render(ctx) == rv
env.intercepted_binops = frozenset(['+'])
t = env.from_string('{{ %s }}' % expr)
- try:
+ with pytest.raises(TemplateRuntimeError):
t.render(ctx)
- except TemplateRuntimeError as e:
- pass
- else:
- assert False, 'expected runtime error'
def test_unary_operator_intercepting(self, env):
def disable_op(arg):
assert t.render(ctx) == rv
env.intercepted_unops = frozenset(['-'])
t = env.from_string('{{ %s }}' % expr)
- try:
+ with pytest.raises(TemplateRuntimeError):
t.render(ctx)
- except TemplateRuntimeError as e:
- pass
- else:
- assert False, 'expected runtime error'
@pytest.mark.sandbox