2

I want to run a directory of tests multiple times.

In How can I repeat each test multiple times in a py.test run?, an answer was given to use module pytest-repeat. This module allows you to use a --count=n argument.

That argument makes pytest run each testcase inside of each test module n times in a row, before moving on to the next testcase, and then to the next test module.

This is a problem when tests are non re-entrant - the teardown code needs to be executed in order for repeated runs to succeed, or subsequent tests to succeed.

I want a way to run the entire directory, top-to-bottom, and then run it again top-to-bottom, etc., n times.

Barring that, I want a way to run each individual test module from beginning to end n times, rather than running each testcase inside the module n times.

In fewer words: The --count=n argument provided by the pytest-repeat module incurs repetition at the testcase level. I want repetition at the test module level, or, better yet, at the directory level.

Yaron Shragai
  • 137
  • 11

1 Answers1

2

I want a way to run the entire directory, top-to-bottom, and then run it again top-to-bottom, etc., n times.

You can do this with a bit of shell.

for i in {1..5}; do echo "Run ${i}"; pytest; done;
Schwern
  • 153,029
  • 25
  • 195
  • 336