I use nose 1.1.2 to write tests for a Python project. There is a function assert_raisesthat is mentioned in the documentation, but I cannot find it.
This should be a shorthand for something like this:
value_error_raised = False
try:
do_something_that_should_raise_value_error()
except ValueError:
value_error_raised = True
assert value_error_raised
type_error_raised = False
try:
do_something_else_that_should_raise_type_error()
except TypeError:
type_error_raised = True
assert type_error_raised
which will be as follows:
assert_raises(ValueError,
do_something_that_should_raise_value_error)
assert_raises(TypeError,
do_something_else_that_should_raise_type_error)
I was already looking for the source code, and the only mention I found was in the tools.py module inside the documentation raises:
If you want to test many exception statements in one test, you can use instead assert_raises.
Has this feature been removed from the nose? If so, can someone help me understand why?
source
share