Fix test_not_found
This commit is contained in:
parent
f38dda5f16
commit
0bd3100de8
@ -58,7 +58,7 @@ html_fallback = """<!DOCTYPE html>
|
|||||||
<img style="width: 100%; display: block; max-width: 256px;" src="{{ data_url("img/broken_qutebrowser_logo.png") }}" />
|
<img style="width: 100%; display: block; max-width: 256px;" src="{{ data_url("img/broken_qutebrowser_logo.png") }}" />
|
||||||
</td>
|
</td>
|
||||||
<td style="padding-left: 40px;">
|
<td style="padding-left: 40px;">
|
||||||
<p><span style="font-size:120%;color:red">The error.html template could not be found!<br>Please check your qutebrowser installation</span><br>
|
<p><span style="font-size:120%;color:red">The %FILE% template could not be found!<br>Please check your qutebrowser installation</span><br>
|
||||||
%ERROR%</p>
|
%ERROR%</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -85,7 +85,9 @@ class Loader(jinja2.BaseLoader):
|
|||||||
source = utils.read_file(path)
|
source = utils.read_file(path)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
source = html_fallback.replace("%ERROR%", html.escape(str(e)))
|
source = html_fallback.replace("%ERROR%", html.escape(str(e)))
|
||||||
log.misc.error("The error.html template could not be found at " + path)
|
source = source.replace("%FILE%", html.escape(template))
|
||||||
|
log.misc.error("The {} template could not be found at {}".format(
|
||||||
|
template, path))
|
||||||
# Currently we don't implement auto-reloading, so we always return True
|
# Currently we don't implement auto-reloading, so we always return True
|
||||||
# for up-to-date.
|
# for up-to-date.
|
||||||
return source, path, lambda: True
|
return source, path, lambda: True
|
||||||
|
@ -105,11 +105,15 @@ def test_data_url():
|
|||||||
assert data == 'data:text/plain;base64,Zm9v' # 'foo'
|
assert data == 'data:text/plain;base64,Zm9v' # 'foo'
|
||||||
|
|
||||||
|
|
||||||
def test_not_found():
|
def test_not_found(caplog):
|
||||||
"""Test with a template which does not exist."""
|
"""Test with a template which does not exist."""
|
||||||
with pytest.raises(jinja2.TemplateNotFound) as excinfo:
|
with caplog.at_level(logging.ERROR):
|
||||||
jinja.render('does_not_exist.html')
|
data = jinja.render('does_not_exist.html')
|
||||||
assert str(excinfo.value) == 'does_not_exist.html'
|
assert "The does_not_exist.html template could not be found!" in data
|
||||||
|
|
||||||
|
assert len(caplog.records) == 1
|
||||||
|
assert caplog.records[0].msg.startswith("The does_not_exist.html template"
|
||||||
|
" could not be found at")
|
||||||
|
|
||||||
|
|
||||||
def test_utf8():
|
def test_utf8():
|
||||||
|
Loading…
Reference in New Issue
Block a user