summaryrefslogtreecommitdiff
path: root/tests/test_api.py
diff options
context:
space:
mode:
authorKevin Brown <kevin@kevin-brown.com>2019-10-10 02:15:15 -0400
committerKevin Brown <kevin@kevin-brown.com>2019-10-10 02:32:29 -0400
commitca72c5f301d1aa2ce0e75b440dc6364b4a69bbeb (patch)
tree5286cd51e11f0b1b343453c043618781514f44de /tests/test_api.py
parent0b9d252a071b0b5a171e1308157da74aa079b9d8 (diff)
downloadjinja2-pytest-cleanup.tar.gz
Replaced try...catch within tests with pytest.raisespytest-cleanup
This still leaves one in test_debug which relies on reading out the traceback and cannot easily be replaced by pytest.raises like the others.
Diffstat (limited to 'tests/test_api.py')
-rw-r--r--tests/test_api.py12
1 files changed, 2 insertions, 10 deletions
diff --git a/tests/test_api.py b/tests/test_api.py
index e37d5cf..1829b1d 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -336,20 +336,12 @@ class TestUndefined(object):
pytest.raises(UndefinedError, t.render, var=0)
def test_none_gives_proper_error(self):
- try:
+ with pytest.raises(UndefinedError, match= "'None' has no attribute 'split'"):
Environment().getattr(None, 'split')()
- except UndefinedError as e:
- assert e.message == "'None' has no attribute 'split'"
- else:
- assert False, 'expected exception'
def test_object_repr(self):
- try:
+ with pytest.raises(UndefinedError, match="'int object' has no attribute 'upper'"):
Undefined(obj=42, name='upper')()
- except UndefinedError as e:
- assert e.message == "'int object' has no attribute 'upper'"
- else:
- assert False, 'expected exception'
@pytest.mark.api