The specific exception types that are thrown internally by unittest2 are considered implementation details and even documented as such in the source code of the library. This patch attempts to make this correct by removing reliance on these implementation details, and deferring to the library implementation.
I'm not sure I have a good grasp of how all these decorators are supposed to work, but I think I did this right. Please verify carefully that I didn't mess anything up.
The goal of this patch is to make a conditionalExpectedFailure decorator that has the following behavior:
- If the "condition" is true (i.e. this is an expected failure), reuse the library's expectedFailure decorator.
- If the condition is false (i.e. this is not an expected failure), just call the method.
You are swallowing the bug number here
Based on the implementation of unittest2.expectedFailure I think you should write the following to preserve it (I haven't tested it):