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

Parallelize tests using pytest-xdist #820

Merged
merged 3 commits into from
Feb 3, 2025

Conversation

sorasful
Copy link
Contributor

Hi there!

I've noticed that the tests took a little while to run. So I've decided to see if we could parallelize them, I used pytest-xdist.

For very few tests (3), concurrency was a problem so I've decided to run them sequentially. I followed this issue to implement this :

pytest-dev/pytest-xdist#385

Now everything runs smoothly and quickly.

Copy link

codecov bot commented Jan 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (a43c359) to head (be3831b).
Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #820   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          138       138           
  Lines        11044     11074   +30     
  Branches      1565      1569    +4     
=========================================
+ Hits         11044     11074   +30     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -61,6 +61,7 @@ def celery_worker(celery_app: Celery) -> Iterator[WorkController]:
yield worker


@pytest.mark.xdist_group(name='sequential')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm removing this one because I think this test is just flaky, I can't see evidence that xdist makes this fail more often.

.gitignore Outdated Show resolved Hide resolved
@alexmojaki alexmojaki requested a review from Kludex February 3, 2025 11:22
@alexmojaki
Copy link
Contributor

@sorasful awesome, thanks for the speedup! Is there a way to make it use xdist by default, e.g. when I run pytest in the terminal, or run pytest through my IDE? Maybe a setting in pyproject.toml?

@alexmojaki alexmojaki enabled auto-merge (squash) February 3, 2025 11:50
@alexmojaki alexmojaki merged commit 3715989 into pydantic:main Feb 3, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants