[TIP] aborting tests that take too long
gary.bernhardt at gmail.com
Thu Nov 10 15:43:55 PST 2011
As a quick and dirty solution, you could start a thread that calls
thread.interrupt_main() after n seconds. You'd need to wire it into
the test case with setup/teardown, but it should do the trick. Code
below ("done" never gets printed).
import sys, time, thread, threading
t = threading.Thread(target=kill_main_thread)
On Thu, Nov 10, 2011 at 7:28 AM, Mark Sienkiewicz <sienkiew at stsci.edu> wrote:
> I have a general problem with tests that deadlock, go into an infinite loop,
> or otherwise just run for way too long. I need to do something about this
> because it is starting to become a problem in my CI system.
> When a test takes too long, I don't just want the test to fail if it takes
> too long -- I want it to be forced to stop running. Is there some way to do
> this in py.test or nose?
> Mark S.
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
More information about the testing-in-python