We have a bunch of tests that call Python C/C++ bindings. We run these tests with nose:
nosetests myapp
.....
----------------------------------------------------------------------
Ran 5 tests in 0.009s
Sometimes, it happens that our bindings are buggy, causing the Python interpreter to crash, say, on test number 3:
test03_badcode (myapp.tests.test_badcode) ... Segmentation fault
Question: What is the best way to recover from this? Ideally, I would prefer nose handled these crashes itself, but I understand this is impossible to achieve. The next solution I thought of would be to take note of the test and re-start nose, now skipping the bad test. In my example, this would mean to execute tests 1, 2, 4 and 5, but not test 3. Is there a way to achieve this programatically with nose? Any other better ideas?
As usual with nose, there's a plugin for that. Insulate will run each test in a separate process. That will slow things down, but you're guaranteed that a crash in one test won't affect the others.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With