Unit Test Problem with assertRaises

Be careful if you're using factory boy, this package doesn't allow the exception to be raised to the assert level which will always fail


self.assertRaises expects a function mro.setStatus, followed by an arbitrary number of arguments: in this case, just NEW_STATUS. self.assertRaises assembles its arguments into the function call mro.setStatus(NEW_STATUS) inside a try...except block, thus catching and recording the ValueError if it occurs.

Passing mro.setStatus(NEW_STATUS) as an argument to self.assertRaises causes the ValueError to occur before self.assertRaises can trap it.

So the fix is to change the parentheses to a comma:

self.assertRaises(ValueError,mro.setStatus,NEW_STATUS)