Skip to content

Commit 568a645

Browse files
danceratopzpacrob
authored andcommitted
fix(fill): fix reported fixture source urls for the case of auto-generated tests (ethereum#1488)
1 parent b2025e8 commit 568a645

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

docs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Test fixtures for use by clients are available for each release on the [Github r
1212

1313
#### `fill`
1414

15+
- 🐞 Fix the reported fixture source URLs for the case of auto-generated tests ([#1488](https://github.com/ethereum/execution-spec-tests/pull/1488)).
16+
1517
#### `consume`
1618

1719
### 📋 Misc

src/pytest_plugins/filler/filler.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,12 +659,22 @@ def fixture_source_url(
659659
if hasattr(request.node, "github_url"):
660660
return request.node.github_url
661661
function_line_number = request.function.__code__.co_firstlineno
662-
module_relative_path = os.path.relpath(request.module.__file__)
662+
module_relative_path = os.path.relpath(request.function.__code__.co_filename)
663+
663664
github_url = generate_github_url(
664665
module_relative_path,
665666
branch_or_commit_or_tag=commit_hash_or_tag,
666667
line_number=function_line_number,
667668
)
669+
test_module_relative_path = os.path.relpath(request.module.__file__)
670+
if module_relative_path != test_module_relative_path:
671+
# This can be the case when the test function's body only contains pass and the entire
672+
# test logic is implemented as a test generator from the framework.
673+
test_module_github_url = generate_github_url(
674+
test_module_relative_path,
675+
branch_or_commit_or_tag=commit_hash_or_tag,
676+
)
677+
github_url += f" called via `{request.node.originalname}()` in {test_module_github_url}"
668678
return github_url
669679

670680

0 commit comments

Comments
 (0)