diff options
author | Kevin Brown <kevin@kevin-brown.com> | 2019-10-10 02:15:15 -0400 |
---|---|---|
committer | Kevin Brown <kevin@kevin-brown.com> | 2019-10-10 02:32:29 -0400 |
commit | ca72c5f301d1aa2ce0e75b440dc6364b4a69bbeb (patch) | |
tree | 5286cd51e11f0b1b343453c043618781514f44de /tests/test_api.py | |
parent | 0b9d252a071b0b5a171e1308157da74aa079b9d8 (diff) | |
download | jinja2-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.py | 12 |
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 |