pytest-dev / pytest-repeat

pytest plugin for repeating test execution
https://pypi.python.org/pypi/pytest-repeat/
Other
172 stars 27 forks source link

Request Feature: support for unittest repeat #18

Closed fenchu closed 4 years ago

fenchu commented 6 years ago
$ pytest --version
This is pytest version 3.4.1, imported from /home/mortenb/.pyenv/versions/3.6.4/envs/unity/lib/python3.6/site-packages/pytest.py
setuptools registered plugins:
  pytest-repeat-0.4.1 at /home/mortenb/.pyenv/versions/3.6.4/envs/unity/lib/python3.6/site-packages/pytest_repeat.py

If I use --count=N It runs the tests one time then issue this warning for the unittests it discovered:

UserWarning: Repeating unittest class tests not supported "Repeating unittest class tests not supported")

There are two ways currently to repeat a unittest N times ./mytest.py T.test1 T.test1 .. N-1Time NTime (not very practical when you want 1000 :-) )

Or you can like your own testrunner:

Ntimes = 10
    testlist = [tfunc for tfunc in sorted(dir(T)) if callable(getattr(T, tfunc)) and str(tfunc).startswith('test')]
    suite = unittest.TestSuite()
    for t in testlist:
        if t=='<testname to run>':
            for i in range(Ntimes):
                suite.addTest(T(t))
    runner = unittest.TextTestRunner(verbosity=2, failfast=True)
    runner.run(suite)
The-Compiler commented 6 years ago

Duplicate of #3