Skip a unit test from a Nose2 Plugin

Tuesday, July 8, 2014

I'm having trouble actually skipping a unit test from a Nose2 plugin. I am able to mark the test skipped and see the reason in the final result, but the test still runs. This example code should basically skip any test, as long as the plugin is active.

from import Plugin

class SkipAllTests(Plugin):
def startTest(self, event):
event.result.addSkip(event.test, 'skip it')
event.handled = True

If I call event.test.skipTest('reason') it actually raises the SkipTest exception like it should, it's just that the exception isn't caught by the test runner, it just raises inside of my startTest hook method. Any ideas?