DataDog / dd-trace-py

Datadog Python APM Client
https://ddtrace.readthedocs.io/
Other
504 stars 396 forks source link

fix(ci_visibility): properly resolve decorated functions for test source file information [backport 2.9] #9644

Closed romainkomorndatadog closed 4 days ago

romainkomorndatadog commented 5 days ago

Backport 203e89489f1e698a127317dc57b01e9d6467e859 from #9586 to 2.9.

Fixes an issue where decorated test functions could resolve to the wrong location when certain decorators (eg: @mock.patch) were used.

This also fixes the fact that source file info paths might not always be relative to the current repo root.

The test added in this PR verifies the above by using a variety of decorators as well as executing from the nested_dir directory instead of the git repo root, with the source file info properly showing the path as nested_dir/test_mydecorators.py.

Checklist

Reviewer Checklist

pr-commenter[bot] commented 5 days ago

Benchmarks

Benchmark execution time: 2024-06-26 14:56:01

Comparing candidate commit 2cf677fc5a02cd689c90a88f92b0e2c6e87df901 in PR branch backport-9586-to-2.9 with baseline commit 072486e6ceb3cb036bb307b3025ca3bfc559155d in branch 2.9.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 209 metrics, 9 unstable metrics.