Python Tests

Python Tests

Compatibility

Supported CI providers:

  • Appveyor
  • Azure Pipelines
  • BitBucket
  • BuildKite
  • CircleCI
  • GitHub Actions
  • GitLab
  • Jenkins
  • TravisCI

Prerequisites

Install the Datadog Agent to collect tests data.

Installing tracing

Install the Python tracer by running:

pip install ddtrace

For more information, see the Python tracer installation documentation.

Instrumenting your Pytest tests

To enable instrumentation of pytest tests, add the --ddtrace option when running pytest:

pytest --ddtrace

You can also add the following configuration to any file used to configure pytest (such as pytest.ini or setup.cfg):

[pytest]
ddtrace = 1

Configuration parameters

ddtrace.config.pytest["service"]
The service name reported by default for pytest traces.
Environment variable: DD_PYTEST_SERVICE
Default: "pytest"
ddtrace.config.pytest["operation_name"]
The operation name reported by default for pytest traces.
Environment variable: DD_PYTEST_OPERATION_NAME
Default: "pytest.test"

Further reading