Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't use xdist when running a subset of unittests
Context: When running `make test` or `tox` h uses pytest-xdist (https://pytest-xdist.readthedocs.io/, activated by the `--numprocesses logical` and `--dist loadgroup` options to `pytest`) to run the unit tests in parallel (one worker per CPU core). Running the tests in parallel is much faster when running a lot of tests. But it adds extra startup time so it actually takes longer if only running a few tests. This is why running the tests in parallel is optional in the cookiecutter and has only been added to h and LMS: in other projects it'd actually take longer. Problem: when running only a subset of h's tests with a command like `tox tests/unit/h/services/group_members_test.py` running them in parallel actually takes longer due to the extra startup time. Also if you've put any `breakpoints()` in the code they will not work: pytest-xdist isn't compatible with pdb. Solution: move the `--numprocesses logical --dist loadgroup` options into the `{posargs:<default_value>}` in `tox.ini`. This means that when you just run `make test` or `tox` the default `posargs` will apply and `--numprocesses logical --dist loadgroup` will be included. But when you override the default posargs with a command like `tox tests/unit/h/services/group_members_test.py` pytest-xdist will not be used. You can still use xdist when running a subset of tests with a command like this: tox -- --numprocesses logical --dist loadgroup tests/unit/h/services/group_members_test.py
- Loading branch information