-
Notifications
You must be signed in to change notification settings - Fork 78
Closed
Description
The Nim testrunner has a handy "expect" context that ensures that the expected exception is thrown. It works like this:
test "Making sure that this throws a RangeError":
expect RangeError:
var a = myArray[-1]
I'm wondering if something like this can be added to assertpy. Right now the docs say to do this:
try:
some_func('bad arg')
fail('should have raised error')
except ValueError, ex:
assert_that(ex.message).contains('some msg')
...But something like this might be nice:
assert_that(some_func('bad arg')).raises(RuntimeError).with_message("some msg")
Or maybe this:
assert_that(RuntimeError).is_raised_by(some_func('bad arg')) # don't care about message
assert_that(RuntimeError).is_raised_by(some_func('bad arg')).with_message("some msg")
Reactions are currently unavailable