Run python unittest until it fails

Viewed 84

I have a Python unittest.TestCase that sometime fails. To debug this, I would like to run automatically run it until it fails. I found https://pypi.org/project/pytest-repeat/ which looks like what I am looking for, but it explicitly says

Unfortunately pytest-repeat is not able to work with unittest.TestCase test classes. These tests will simply always run once, regardless of --count, and show a warning.

Is there something similar that works with unittest?

As I am writing this, it occurs to me that a simple shell command might be the solution:

while pytest ...
do
  echo Sadly, it passed again
done

Is that the actual solution, or is there some python tool that does what I want (possibly better in some way)?

1 Answers

Could a simple try and except work? Just have a while(true) loop with a break in the except statement.

I'm fairly new to python so apologies if the question is way above this answer.

Related