4

I have a few unit tests written using pytest that have successfully caused segfaults to occur. However if a segfault occurs (on my Mac) during these execution, pytest seems to quit altogether and provide no information on what caused the python interpreter to crash.

Now I could infer from the logs the specific test that was crashing and determine the values used within, but I was wondering if there was any way to be able to somehow log the crash as a regular test failure and keep iterating through my tests without stopping?

If helpful, I can try to conceive an example but I think the question should be pretty self-explanatory.

2
  • py.test is also running in Python, so if the interpreter crashes entirely so does the testing; there's no Python exception to catch and you will have to debug that at the OS level. Commented Aug 18, 2015 at 16:59
  • And where does one begin to look for that? The py.test log in my case shows the last thing to be done was executing a command that does not result in any crashes, so there's something else happening that pytest cannot see. Commented Apr 11, 2019 at 15:50

1 Answer 1

6

Using the pytest-xdist plugin it will restart the nodes automatically when they crash, so installing the plugin and running the tests with -n1 should make py.test survive the crashing tests.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.