Skip to content

Import restrictions on test modules - #7408

Open
nccatoni wants to merge 13 commits into
mainfrom
nccatoni/pytest-facade
Open

Import restrictions on test modules#7408
nccatoni wants to merge 13 commits into
mainfrom
nccatoni/pytest-facade

Conversation

@nccatoni

@nccatoni nccatoni commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Motivation

Restricting imports in test modules makes it possible to enforce certain system-test usage patterns that would otherwise require manual review. There are currently two targeted patterns:

  • Preventing imports across test modules.
  • Restricting pytest imports to a limited feature set, notably to prevent the use of native pytest decorators instead of the framework-provided decorators.

Changes

Workflow

  1. ⚠️ Create your PR as draft ⚠️
  2. Work on you PR until the CI passes
  3. Mark it as ready for review
    • Test logic is modified? -> Get a review from RFC owner.
    • Framework is modified, or non obvious usage of it -> get a review from R&P team

🚀 Once your PR is reviewed and the CI green, you can merge it!

🛟 #apm-shared-testing 🛟

Reviewer checklist

  • Anything but tests/ or manifests/ is modified ? I have the approval from R&P team
  • A docker base image is modified?
    • the relevant build-XXX-image label is present
  • A scenario is added, removed or renamed?

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jul 29, 2026

Copy link
Copy Markdown

Pipelines  Tests

⚠️ Warnings

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 1 Pipeline job failed

Testing the test | all-jobs-are-green

View more details · View in GitHub Actions

Some checks are still running, but retries have been exhausted.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🔄 Datadog auto-retried 29 jobs - 28 passed on retry View in Datadog

Useful? React with 👍 / 👎

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

@nccatoni
nccatoni force-pushed the nccatoni/pytest-facade branch from b66c820 to 7dfc221 Compare August 12, 2026 12:26
@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

CODEOWNERS have been resolved as:

.importlinter                                                           @DataDog/system-tests-core
utils/format/__init__.py                                                @DataDog/system-tests-core
utils/format/import_linter_contracts.py                                 @DataDog/system-tests-core
utils/pytest.py                                                         @DataDog/system-tests-core
.cursor/rules/code-format-standards.mdc                                 @DataDog/system-tests-core
.cursor/rules/pr-review.mdc                                             @DataDog/system-tests-core
.cursor/rules/repository-structure.mdc                                  @DataDog/system-tests-core
.cursor/rules/test-activation.mdc                                       @DataDog/system-tests-core
format.sh                                                               @DataDog/system-tests-core
pyproject.toml                                                          @DataDog/system-tests-core
requirements.txt                                                        @DataDog/system-tests-core
tests/ai_guard/conftest.py                                              @DataDog/k9-ai-guard @DataDog/system-tests-core
tests/appsec/waf/test_addresses.py                                      @DataDog/asm-libraries @DataDog/system-tests-core
tests/ffe/test_flag_eval_evp.py                                         @DataDog/feature-flagging-and-experimentation-sdk @DataDog/system-tests-core
tests/integration_frameworks/conftest.py                                @DataDog/system-tests-core
tests/integration_frameworks/llm/anthropic/test_anthropic_ai_guard.py   @DataDog/ml-observability
tests/integration_frameworks/llm/anthropic/test_anthropic_apm.py        @DataDog/ml-observability
tests/integration_frameworks/llm/anthropic/test_anthropic_llmobs.py     @DataDog/ml-observability
tests/integration_frameworks/llm/google_genai/test_google_genai_apm.py  @DataDog/ml-observability
tests/integration_frameworks/llm/google_genai/test_google_genai_llmobs.py  @DataDog/ml-observability
tests/integration_frameworks/llm/openai/test_openai_ai_guard.py         @DataDog/ml-observability
tests/integration_frameworks/llm/openai/test_openai_apm.py              @DataDog/ml-observability
tests/integration_frameworks/llm/openai/test_openai_llmobs.py           @DataDog/ml-observability
tests/parametric/conftest.py                                            @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_128_bit_traceids.py                               @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_config_consistency.py                             @DataDog/apm-sdk-capabilities
tests/parametric/test_crashtracking.py                                  @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_dynamic_configuration.py                          @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_extract_behavior.py                               @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_ffe/test_configuration_sources.py                 @DataDog/feature-flagging-and-experimentation-sdk @DataDog/system-tests-core
tests/parametric/test_ffe/test_dynamic_evaluation.py                    @DataDog/feature-flagging-and-experimentation-sdk @DataDog/system-tests-core
tests/parametric/test_ffe/test_span_enrichment.py                       @DataDog/feature-flagging-and-experimentation-sdk @DataDog/system-tests-core
tests/parametric/test_headers_b3.py                                     @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_headers_b3multi.py                                @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_headers_baggage.py                                @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_headers_none.py                                   @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_headers_opm.py                                    @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_headers_precedence.py                             @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_headers_tracecontext.py                           @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_headers_tracestate_dd.py                          @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_library_tracestats.py                             @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_llm_observability/conftest.py                     @DataDog/ml-observability @DataDog/system-tests-core
tests/parametric/test_llm_observability/test_llm_observability.py       @DataDog/ml-observability @DataDog/system-tests-core
tests/parametric/test_llm_observability/test_llm_observability_dne.py   @DataDog/ml-observability @DataDog/system-tests-core
tests/parametric/test_llm_observability/utils.py                        @DataDog/ml-observability @DataDog/system-tests-core
tests/parametric/test_otel_api_interoperability.py                      @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_otel_env_vars.py                                  @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_otel_logs.py                                      @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_otel_metrics.py                                   @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_otel_span_methods.py                              @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_otel_span_with_baggage.py                         @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_otel_tracer.py                                    @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_otel_tracestate_sampling.py                       @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_otlp_trace_metrics.py                             @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_parametric_endpoints.py                           @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_partial_flushing.py                               @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_process_discovery.py                              @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_sampling_delegation.py                            @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_sampling_manual.py                                @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_sampling_span_tags.py                             @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_span_events.py                                    @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_span_links.py                                     @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_span_sampling.py                                  @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_startup_logs.py                                   @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_telemetry.py                                      @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_trace_filters.py                                  @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_trace_sampling.py                                 @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_tracer.py                                         @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/test_tracer_flare.py                                   @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/parametric/utils.py                                               @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
tests/stats/test_stats.py                                               @DataDog/system-tests-core
tests/test_library_conf.py                                              @DataDog/system-tests-core
tests/test_the_test/scenarios.json                                      @DataDog/system-tests-core
tests/test_the_test/test_ai_guard_span_helpers.py                       @DataDog/system-tests-core
tests/test_the_test/test_build_pipeline.py                              @DataDog/system-tests-core
tests/test_the_test/test_compute_libraries_and_scenarios.py             @DataDog/system-tests-core
tests/test_the_test/test_decorators.py                                  @DataDog/system-tests-core
tests/test_the_test/test_deserializer.py                                @DataDog/system-tests-core
tests/test_the_test/test_docker_run_cleanup.py                          @DataDog/system-tests-core
tests/test_the_test/test_docker_scenario.py                             @DataDog/system-tests-core
tests/test_the_test/test_easy_win.py                                    @DataDog/system-tests-core
tests/test_the_test/test_external_gitlab_pipeline.py                    @DataDog/system-tests-core
tests/test_the_test/test_features.py                                    @DataDog/system-tests-core
tests/test_the_test/test_force_option.py                                @DataDog/system-tests-core
tests/test_the_test/test_get_image_list.py                              @DataDog/system-tests-core
tests/test_the_test/test_github_nightly.py                              @DataDog/system-tests-core
tests/test_the_test/test_json_report.py                                 @DataDog/system-tests-core
tests/test_the_test/test_junit.py                                       @DataDog/system-tests-core
tests/test_the_test/test_manifest.py                                    @DataDog/system-tests-core
tests/test_the_test/test_minimal_number_of_scenarios.py                 @DataDog/system-tests-core
tests/test_the_test/test_mock_ffe_agentless_backend.py                  @DataDog/feature-flagging-and-experimentation-sdk @DataDog/system-tests-core
tests/test_the_test/test_scrubber.py                                    @DataDog/system-tests-core
tests/test_the_test/test_slow_and_crash_decorators.py                   @DataDog/system-tests-core
tests/test_the_test/test_telemetry_heartbeat.py                         @DataDog/system-tests-core
tests/test_the_test/test_update_mirror_images.py                        @DataDog/system-tests-core
tests/test_the_test/test_version.py                                     @DataDog/system-tests-core
utils/ci/gitlab/main.yml                                                @DataDog/system-tests-core

@nccatoni
nccatoni marked this pull request as ready for review August 12, 2026 13:29
@nccatoni
nccatoni requested review from a team as code owners August 12, 2026 13:29
@nccatoni
nccatoni requested review from sameerank, vjfridge and zacharycmontoya and removed request for a team August 12, 2026 13:29
@nccatoni nccatoni changed the title Import linting Impose import restriction on test modules Aug 12, 2026
@nccatoni nccatoni changed the title Impose import restriction on test modules Import restrictions on test modules Aug 12, 2026
Comment thread tests/test_the_test/test_slow_and_crash_decorators.py
Comment thread utils/scripts/shellcheck.sh Outdated
Comment thread utils/pytest.py Outdated
Comment thread utils/format/import_linter_contracts.py
@nccatoni
nccatoni requested a review from cbeauchesne August 26, 2026 13:24
@nccatoni
nccatoni enabled auto-merge (squash) August 26, 2026 13:50

@zacharycmontoya zacharycmontoya left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM for the parametric tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants