Skip to content

assertion rewriting ignores the original source positions #12818

@15r10nk

Description

@15r10nk

The assertion rewriting in pytest changes the source position for all nodes in the assertion to the source range of the assertion.

for stmt in self.statements:
for node in traverse_node(stmt):
ast.copy_location(node, assert_)

This causes problems for tools like executing which uses these source ranges (since python 3.11) to provide a mapping back to the ast-node.

This causes the following problems.

I already created a pull-request to solve this problem #12815.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions