Skip to content

Commit

Permalink
fixup! test: use pytest.raises
Browse files Browse the repository at this point in the history
  • Loading branch information
fbotner committed Nov 9, 2022
1 parent 8dfa3d5 commit 3f873ea
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions tests/test_base_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,15 +719,14 @@ async def test_modify_error_exception(user_created_via_http, udm_kwargs, error):
obj = await mod.get(dn)
assert obj.dn == dn
obj.props[attribute] = value
try:
with pytest.raises(ModifyError) as exc_info:
await obj.save()
assert False # pragma: no cover
except ModifyError as e:
assert str(e) == msg
assert e.reason == "Unprocessable Entity"
assert isinstance(e.dn, str)
assert isinstance(e.error, dict)
assert isinstance(e.status, int)
exc = exc_info.value
assert str(exc) == msg
assert exc.reason == "Unprocessable Entity"
assert isinstance(exc.dn, str)
assert isinstance(exc.error, dict)
assert isinstance(exc.status, int)


@pytest.mark.asyncio
Expand Down Expand Up @@ -757,15 +756,14 @@ async def test_create_error_exception(udm_kwargs, error, faker):
obj.props.lastname = faker.unique.user_name()
obj.props.password = "univention"
obj.props[attribute] = value
try:
with pytest.raises(CreateError) as exc_info:
await obj.save()
assert False # pragma: no cover
except CreateError as e:
assert str(e) == msg
assert e.reason == "Unprocessable Entity"
assert e.dn is None
assert isinstance(e.error, dict)
assert isinstance(e.status, int)
exc = exc_info.value
assert str(exc) == msg
assert exc.reason == "Unprocessable Entity"
assert exc.dn is None
assert isinstance(exc.error, dict)
assert isinstance(exc.status, int)


@pytest.mark.asyncio
Expand Down

0 comments on commit 3f873ea

Please sign in to comment.