A folder containing an N amount of functional tests are properly being discovered by nose and executed. I would like to be able to interrupt the suite at any point but so far nose stops the currently running test and proceeds to the next.
How do you properly quit nose if, for example, a KeyboardInterrupt occurs halfway through the suite?
I fixed the problem by capturing the SIGINT and in its handler set a global value. This value is checked in the setUp() fixture and if set raises the SkipTest for every following test in the suite.
This way the currently running test is allowed to complete after which all following tests are skipped.
from nose.plugins.skip import Skip, SkipTest
test_interrupted = False
class Test_something:
def __init__(self):
...
signal.signal(signal.SIGINT, self.signalHandler)
def signalHandler(self, signal, frame):
global test_interrupted
test_interrupted = True
def setup(self):
if test_interrupted:
raise SkipTest
...