docs(python): pytest-xdist reference (#16231)

Partially resolves https://github.com/microsoft/playwright-python/issues/1442.

Tests: https://github.com/microsoft/playwright-pytest/pull/128.
This commit is contained in:
Ross Wollman 2022-08-04 22:12:05 -07:00 committed by GitHub
parent 5d7e80bed6
commit e224159683
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View file

@ -47,6 +47,14 @@ You can run a single test, a set of tests or all tests. Tests can be run on one
pytest test_login.py --browser webkit --browser firefox
```
- Running Tests in parallel
```bash
pytest --numprocesses auto
```
(This assumes `pytest-xdist` is installed. For more information see [here](./test-runners.md#parallelism-running-multiple-tests-at-once).)
For more information see [Playwright Pytest usage](./test-runners.md) or the Pytest documentation for [general CLI usage](https://docs.pytest.org/en/stable/usage.html).
## Running Tests

View file

@ -63,6 +63,21 @@ def test_my_app_is_working(fixture_name):
- `browser_type_launch_args`: Override launch arguments for [`method: BrowserType.launch`]. It should return a Dict.
- `browser_context_args`: Override the options for [`method: Browser.newContext`]. It should return a Dict.
## Parallelism: Running Multiple Tests at Once
If your tests are running on a machine with a lot of CPUs, you can speed up the overall execution time of your test suite by using [`pytest-xdist`](https://pypi.org/project/pytest-xdist/) to run multiple tests at once:
```bash
# install dependency
pip install pytest-xdist
# use the --numprocesses flag
pytest --numprocesses auto
```
Depending on the hardware and nature of your tests, you can set `numprocesses` to be anywhere from `2` to the number of CPUs on the machine. If set too high, you may notice unexpected behavior.
See [Running Tests](./running-tests.md) for general information on `pytest` options.
## Examples
### Configure Mypy typings for auto-completion