pytest-dev / pytest

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
https://pytest.org
MIT License
11.64k stars 2.59k forks source link

Refactor underlying data structure of assertions AST from string to something more flexible #12499

Open farbodahm opened 2 weeks ago

farbodahm commented 2 weeks ago

What's the problem this feature will solve?

The current data structure for assertion AST, which contains assertion explanations, is a large chunk of string generated in rewrite.py. This string is then passed to format_explanation for further formatting.

Describe the solution you'd like

Implement a more flexible data structure (such as a tree) to construct the assertion explanations. This structure can then provide the string representation when needed, allowing for greater flexibility and potential improvements in how explanations are handled and formatted.

Alternative Solutions

Additional context