def test_undefined_function(caplog):
 with caplog.at_level(logging.ERROR):
  data = jinja.render('undef.html')
 assert ('There was an error while rendering undef.html' in data)
 assert ("'does_not_exist' is undefined" in data)
 assert data.startswith('<!DOCTYPE html>')
 assert (len(caplog.records) == 1)
 assert (caplog.records[0].msg == 'UndefinedError while rendering undef.html')

def test_undefined_function ( caplog ) : with caplog . at_level ( logging . ERROR ) : data = jinja . render ( 'undef.html' ) assert ( 'There was an error while rendering undef.html' in data ) assert ( "'does_not_exist' is undefined" in data ) assert data . startswith ( '<!DOCTYPE html>' ) assert ( len ( caplog . records ) == 1 ) assert ( caplog . records [ 0 ] . msg == 'UndefinedError while rendering undef.html' )
make sure we dont crash if an undefined function is called .