|
20 | 20 |
|
21 | 21 | config.httplib["distributed_tracing"] = True
|
22 | 22 | patch(httplib=True)
|
| 23 | + |
| 24 | + from pytest import hookimpl |
| 25 | + |
| 26 | + @hookimpl(hookwrapper=True) |
| 27 | + def pytest_terminal_summary(terminalreporter, exitstatus, config): |
| 28 | + yield # do normal output |
| 29 | + |
| 30 | + ci_pipeline_id = os.getenv("GITHUB_RUN_ID", None) |
| 31 | + dd_service = os.getenv("DD_SERVICE", None) |
| 32 | + if ci_pipeline_id and dd_service: |
| 33 | + terminalreporter.ensure_newline() |
| 34 | + terminalreporter.section("test reports", purple=True, bold=True) |
| 35 | + terminalreporter.line( |
| 36 | + "* View test APM traces and detailed time reports on Datadog (can take a few minutes to become available):" |
| 37 | + ) |
| 38 | + terminalreporter.line( |
| 39 | + "* https://app.datadoghq.com/ci/test-runs?query=" |
| 40 | + "%40test.service%3A{}%20%40ci.pipeline.id%3A{}&index=citest".format( |
| 41 | + dd_service, ci_pipeline_id |
| 42 | + ) |
| 43 | + ) |
| 44 | + |
| 45 | + |
23 | 46 | except ImportError:
|
24 | 47 | pass
|
25 | 48 |
|
@@ -62,7 +85,10 @@ def pytest_bdd_before_step(request, feature, scenario, step, step_func):
|
62 | 85 |
|
63 | 86 | context = tracer.get_call_context()
|
64 | 87 | span = tracer.start_span(
|
65 |
| - step.type, resource=step.name, span_type=step.type, child_of=context, |
| 88 | + step.type, |
| 89 | + resource=step.name, |
| 90 | + span_type=step.type, |
| 91 | + child_of=context, |
66 | 92 | )
|
67 | 93 | setattr(step_func, "__dd_span__", span)
|
68 | 94 |
|
@@ -208,9 +234,11 @@ def context(vcr, unique, unique_lower, freezer):
|
208 | 234 | @pytest.fixture(scope="session")
|
209 | 235 | def record_mode(request):
|
210 | 236 | """Manage compatibility with DD client libraries."""
|
211 |
| - return {"false": "none", "true": "rewrite", "none": "new_episodes",}[ |
212 |
| - os.getenv("RECORD", "false").lower() |
213 |
| - ] |
| 237 | + return { |
| 238 | + "false": "none", |
| 239 | + "true": "rewrite", |
| 240 | + "none": "new_episodes", |
| 241 | + }[os.getenv("RECORD", "false").lower()] |
214 | 242 |
|
215 | 243 |
|
216 | 244 | def _disable_recording():
|
|
0 commit comments