How do I stop testing in Python unittest tearDown()? -


i've got large number of tests written using python unittest (python 2.7.8) large testsuite. many of these tests invoke other programs. these other programs dump core. when do, want discover , ensure test fails. if number of cores dumped, want abort entire test environment , exit rather continuing: total test suite has >6000 tests , if dumping core it's useless (and dangerous: disk space etc.) continue.

in order ensure coredumps after every test (so have best possible idea of program/invocation dumped core) decided cores in teardown(), doing successfully. if find core, can run assert variant in teardown() specify test failed.

but can't figure out how give on testing within teardown() if find many cores. tried run sys.exit("too many cores"), unittest case.py catches every exception thrown teardown() except keyboardinterrupt (if try raise hand script hangs until real ^c).

i thought trying call stop(), method on result , can't find way access result object within teardown() (!).

so far option seems to invoke os._exit() annoying because keeps results being reported @ all!

is there no facility in python unittest.testcase tell test environment stop right now, generate results have don't run else?

can check how many cores have been dumped in setup()? if so, call self.skiptest('too many cores dumped.') when things bad.

if don't want cores in setup(), use class variable hold core dump count , check instead.


Popular posts from this blog