Commit 61904bd5 authored by Vincent Michel's avatar Vincent Michel

Add error tests

parent 3d761ade
......@@ -53,3 +53,6 @@ doc/_build/
# PyCharm projects files
.idea
# Coverage
htmlcov
\ No newline at end of file
import pytest
from handel.error import HandelError, check_return_value
@check_return_value
def f(x):
return x
def test_no_error():
assert f(0) is None
def test_known_error():
with pytest.raises(HandelError) as context:
f(801)
assert str(context.value) == '[HandelError 801] UNIT_TEST'
def test_known_error_with_description():
with pytest.raises(HandelError) as context:
f(404)
assert str(context.value) == '[HandelError 404] EOF: EOF encountered'
def test_unknown_error():
with pytest.raises(HandelError) as context:
f(802)
assert str(context.value) == '[HandelError 802] UNKNOWN_ERROR_CODE'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment