Skip to content

Commit

Permalink
Parallelize tests using pytest-xdist
Browse files Browse the repository at this point in the history
  • Loading branch information
sorasful committed Jan 26, 2025
1 parent f4d2c63 commit 2bc8f76
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.env
.idea/
.DS_Store
.logfire
.python-version
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ typecheck:

.PHONY: test # Run the tests
test:
uv run --no-sync coverage run -m pytest
uv run --no-sync coverage run -m pytest -n auto --dist=loadgroup

.PHONY: generate-stubs # Generate stubs for logfire-api
generate-stubs:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ dev = [
"boto3 >= 1.28.57",
"botocore >= 1.31.57",
"greenlet >= 3.1.1",
"pytest-xdist>=3.6.1",
]
docs = [
"black>=23.12.0",
Expand Down
1 change: 1 addition & 0 deletions tests/otel_integrations/test_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def celery_worker(celery_app: Celery) -> Iterator[WorkController]:
yield worker


@pytest.mark.xdist_group(name='sequential')
def test_instrument_celery(celery_app: Celery, exporter: TestExporter) -> None:
# Send and wait for the task to be executed
result = celery_app.send_task('tasks.say_hello') # type: ignore
Expand Down
2 changes: 2 additions & 0 deletions tests/test_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,7 @@ def test_initialize_project_not_confirming_organization(tmp_path: Path) -> None:
]


@pytest.mark.xdist_group(name='sequential')
def test_initialize_project_create_project(tmp_dir_cwd: Path, tmp_path: Path, capsys: pytest.CaptureFixture[str]):
auth_file = tmp_path / 'default.toml'
auth_file.write_text(
Expand Down Expand Up @@ -1161,6 +1162,7 @@ def test_initialize_project_create_project(tmp_dir_cwd: Path, tmp_path: Path, ca
}


@pytest.mark.xdist_group(name='sequential')
def test_initialize_project_create_project_default_organization(tmp_dir_cwd: Path, tmp_path: Path):
auth_file = tmp_path / 'default.toml'
auth_file.write_text(
Expand Down
24 changes: 24 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2bc8f76

Please sign in to comment.