Use pytest.raises() instead of try/catch with asser 0

This is somehow more readable, and enable using the features of pytest's ExeptionInfo (such as errisinstance).
This commit is contained in:
Reuven 2016-03-04 13:30:40 +02:00
parent e7d548595e
commit 4dc2ef19ea
5 changed files with 39 additions and 84 deletions

View file

@ -174,12 +174,9 @@ def test_templates_and_static(test_apps):
assert flask.url_for('admin.static', filename='test.txt') == '/admin/static/test.txt'
with app.test_request_context():
try:
with pytest.raises(TemplateNotFound) as e:
flask.render_template('missing.html')
except TemplateNotFound as e:
assert e.name == 'missing.html'
else:
assert 0, 'expected exception'
assert e.value.name == 'missing.html'
with flask.Flask(__name__).test_request_context():
assert flask.render_template('nested/nested.txt') == 'I\'m nested'