Skip to content

docs: reflect pytest --command support - #124

Merged
gnufede merged 1 commit into
mainfrom
gnufede/ddtest-docs-update
Aug 28, 2026
Merged

docs: reflect pytest --command support#124
gnufede merged 1 commit into
mainfrom
gnufede/ddtest-docs-update

Conversation

@gnufede

@gnufede gnufede commented Aug 28, 2026

Copy link
Copy Markdown
Member

What

Documents that since release 1.7.0, Python/pytest honors --command / DD_TEST_OPTIMIZATION_RUNNER_COMMAND to override the default python -m pytest invocation. PR #123 made PyTest.RunTests and DiscoverTests use commandOverride when
set, so callers can run the pytest console script (or a wrapper) instead of python -m pytest. Previously the docs stated pytest ignored --command.

Updates docs/settings.md, docs/running.md, docs/best_practices.md, and README.md to describe the override and retain PYTEST_ADDOPTS guidance for passing extra pytest flags.

Why

python -m pytest sets sys.argv[0] to pytest's __main__.py, which ddtrace's detect_service incorrectly treats as a test file path, yielding service='pytest' instead of the module name. The pytest console script sets
argv[0]='pytest', which detect_service skips, so service inference is correct. With this change, projects set DD_TEST_OPTIMIZATION_RUNNER_COMMAND=pytest and ddtest runs pytest <files>.

The docs previously claimed pytest ignored --command and that PYTEST_ADDOPTS was the only way to customize the pytest invocation, which is no longer accurate.

Testing

Tested internally in dd-trace-py CI

@gnufede
gnufede marked this pull request as ready for review August 28, 2026 09:29
@gnufede
gnufede requested a review from a team as a code owner August 28, 2026 09:29

@datadog-datadog-us1-prod datadog-datadog-us1-prod Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Datadog Autotest: PASS

More details

The changed documents match the pytest command override behavior. The review found no incorrect or conflicting guidance.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Datadog Autotest · Commit 226041c · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

PR #123 made PyTest.RunTests and DiscoverTests honor commandOverride
(set via --command / DD_TEST_OPTIMIZATION_RUNNER_COMMAND) instead of
hardcoding 'python -m pytest'. Update settings, README, running, and
best_practices docs to describe the override and retain PYTEST_ADDOPTS
guidance for passing extra flags.
@gnufede
gnufede force-pushed the gnufede/ddtest-docs-update branch from 226041c to c6af345 Compare August 28, 2026 09:44
@datadog-datadog-us1-prod

datadog-datadog-us1-prod Bot commented Aug 28, 2026

Copy link
Copy Markdown

Tests  Code Coverage

All CI checks and tests passed.

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 86.47% (+0.03%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c6af345 | Docs | View more details | Give us feedback!

@gnufede
gnufede merged commit 35b0638 into main Aug 28, 2026
19 checks passed
@gnufede
gnufede deleted the gnufede/ddtest-docs-update branch August 28, 2026 09:47
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.

2 participants