Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pytest-xdist to speed up test suite #617

Open
joshuadavidthomas opened this issue Jan 28, 2024 · 1 comment
Open

Add pytest-xdist to speed up test suite #617

joshuadavidthomas opened this issue Jan 28, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@joshuadavidthomas
Copy link

pytest-xdist helps speed up test execution by distribution tests across multiple CPUs. After installing pytest-xdist in the venv, I got a 78% decrease in the test suite run time, from 4 min 18 sec down to 1 min 52 sec.

Before

$ pytest
================================ test session starts ================================
platform linux -- Python 3.12.0, pytest-7.4.4, pluggy-1.4.0
django: version: 4.1.13, settings: siteroot.settings.dev (from ini)
rootdir: /home/josh/projects/linkding
configfile: pytest.ini
plugins: django-4.7.0
collected 545 items

...

=================== 545 passed, 103 warnings in 258.02s (0:04:18) ===================

After

$ python -m pip install pytest-xdist
Collecting pytest-xdist
  Downloading pytest_xdist-3.5.0-py3-none-any.whl.metadata (3.1 kB)
Collecting execnet>=1.1 (from pytest-xdist)
  Using cached execnet-2.0.2-py3-none-any.whl.metadata (2.9 kB)
Requirement already satisfied: pytest>=6.2.0 in /home/josh/.pyenv/versions/linkding-3.12/lib/python3.12/site-packages (from pytest-xdist) (7.4.4)
Requirement already satisfied: iniconfig in /home/josh/.pyenv/versions/linkding-3.12/lib/python3.12/site-packages (from pytest>=6.2.0->pytest-xdist) (2.0.0)
Requirement already satisfied: packaging in /home/josh/.pyenv/versions/linkding-3.12/lib/python3.12/site-packages (from pytest>=6.2.0->pytest-xdist) (23.2)
Requirement already satisfied: pluggy<2.0,>=0.12 in /home/josh/.pyenv/versions/linkding-3.12/lib/python3.12/site-packages (from pytest>=6.2.0->pytest-xdist) (1.4.0)
Using cached pytest_xdist-3.5.0-py3-none-any.whl (42 kB)
Using cached execnet-2.0.2-py3-none-any.whl (37 kB)
Installing collected packages: execnet, pytest-xdist
Successfully installed execnet-2.0.2 pytest-xdist-3.5.0

$ pytest -n auto
================================ test session starts ================================
platform linux -- Python 3.12.0, pytest-7.4.4, pluggy-1.4.0
django: version: 4.1.13, settings: siteroot.settings.dev (from ini)
rootdir: /home/josh/projects/linkding
configfile: pytest.ini
plugins: xdist-3.5.0, django-4.7.0
8 workers [545 items]

...

=================== 545 passed, 125 warnings in 112.78s (0:01:52) ===================
@sissbruecker
Copy link
Owner

Open to this, assuming the current test suite passes with it.

@sissbruecker sissbruecker added the enhancement New feature or request label Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants