0

I want to run one test module for different command line options in parallel. Can this be achieved in pytest? So, for example if I have a test module called test_webservice.py and I am accepting one command line argument while running say, "url". I currently run this one with following command:

python -m pytest test_webservice.py --url "https://example.com"

and then again for a different url as:

python -m pytest test_webservice.py --url "https://example2.com"

Now I want to run test_webservice.py for both the urls in parallel. The test cases remain same, only change is the url. Is there a way to do this using pytest?

Rajat Bhardwaj
  • 129
  • 1
  • 11
  • Possible answers here: https://stackoverflow.com/questions/7207309/python-how-can-i-run-python-functions-in-parallel – Kryesec Jan 16 '19 at 09:23
  • Actually I am looking for a way to run same test cases with different inputs. The answers here serve a slightly different use case. Thanks anyways! :) – Rajat Bhardwaj Jan 16 '19 at 09:33
  • 1
    Use `@pytest.mark.parametrize` marker to run the same test with multiple arguments; see [Parametrizing fixtures and test functions](https://docs.pytest.org/en/latest/parametrize.html). To run the tests in parallel, use the [`xdist`](https://pypi.org/project/pytest-xdist) plugin. – hoefling Jan 16 '19 at 09:43

0 Answers0