I’ve searched for documentation, but couldn’t find any. There were a couple that didn’t explain much.
Can someone explain to me Nose’s
assert_raises(what should I put here?)
function and how to use it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
assert_raises()function tests to make sure a function call raises a specified exception when presented with certain parameters.For example, if you had a function
addthat adds two numbers, it should probably raise aTypeErrorwhen you pass it, say, an integer and a string. So:The first argument is the exception type you expect. The second is the function to call. The rest of the arguments will be passed to the function (in this case, they will become
xandyinside the function).If the expected exception is raised by the function, the assertion passes.