feat(python): add Python/pytest support#91
Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit intoJun 22, 2026
Conversation
c322d50 to
49156a1
Compare
Closed
…87/88/89 Adapt the Python platform and pytest framework implementation to the updated codebase structure introduced by the recent merged PRs: - Implement the new Framework interface: TestPattern() replaces DiscoverTestFiles(), and DiscoverTests() now accepts discovery.TestFileSet from the planner - pytest resolves glob patterns to explicit files (python has no --pattern flag) - Move discovery helpers to the discovery package (Cleanup, DiscoverTests, BaseEnv) - Add DDTestOptimizationManifestFileEnvVar support for dd-trace-py manifest lookup - Add PythonEnvOutputPath constant and DDTEST_LOG_LEVEL debug support in main.go - Update worker_env.go to set both manifest env vars for Python workers Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
49156a1 to
7031c71
Compare
anmarchenko
approved these changes
Jun 22, 2026
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 7031c71 | Docs | Datadog PR Page | Give us feedback! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds Python/pytest support to ddtest, making it possible to use Test Impact Analysis and test skipping for Python projects using pytest.
New platform (
python) and framework (pytest) that integrate with the existing ddtest architecture:runtime.name,runtime.version,os.platform, etc.) from the Python interpreter via an embedded script, and verifies thatddtrace >= 4.10.3is installedpytest.ini,pyproject.toml,tox.ini,setup.cfg) to findtestpathsandpython_files, builds a glob pattern, and passes explicit file paths topython -m pytest(pytest has no--patternflag like RSpec does)--ddtraceintoPYTEST_ADDOPTSso the ddtrace pytest plugin loads automatically without requiring changes to the project's pytest configTEST_OPTIMIZATION_MANIFEST_FILEandDD_TEST_OPTIMIZATION_MANIFEST_FILEin worker env — dd-trace-py reads the latterWhy
Python/pytest is one of the most widely used test stacks. Supporting it in ddtest allows Python teams to benefit from Test Impact Analysis (skipping tests unaffected by a code change), reducing CI time.
E2E testing
Requirements: Python with
ddtrace >= 4.10.3andpytestinstalled, a Datadog API key with Test Optimization enabled.Create a small fixture project:
Run plan then run:
Expected plan output includes
Platform: python / pytest, correct runtime tags (CPython,runtime.version), and discovered tests listed per file. After a few runs with coverage data collected, an unrelated commit (e.g. editing a README) should showSkippable tests for this run: Nwith the full test suites skipped.