pytest icon indicating copy to clipboard operation
pytest copied to clipboard

[refactor] Start using match case in 'assertrepr_compare'

Open Pierre-Sassoulas opened this issue 2 months ago • 1 comments

Following https://github.com/pytest-dev/pytest/pull/13727, there's some potential for match in assertrepr_compare (a lot of isinstance check are hidden inside helper function like isset isttxt, issequence, etc), and maybe some refactor to do to be able to benefit from it (in the case of set here it's to avoid creating the dict at runtime). I'm starting small, but I think it's possible to do more later.

It might be beneficial to extract function from util.py into _compare_cls.py, _compare_dict.py, _compare_iterable.py, _compare_sequence.py, _compare_set.py, _compare_str.py, assertrepr_compare.py, and format_explanation.py first, let me know if you want me to do that so that the initial match refactor PR is more focused. If I don't do that, it's better to review this PR by hiding white spaces and commit by commit.

Pierre-Sassoulas avatar Sep 28 '25 08:09 Pierre-Sassoulas