diff --git a/AUTHORS b/AUTHORS index 0560caf72..2916a7d7d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -292,6 +292,7 @@ Milan Lesnek Miro Hrončok mrbean-bremen Nathan Goldbaum +Nathan Sala Nathaniel Compton Nathaniel Waisbrot Ned Batchelder @@ -442,6 +443,7 @@ Xuan Luong Xuecong Liao Yannick Péroux Yao Xiao +Yechiel Vizel Yoav Caspi Yuliang Shao Yusuke Kadowaki diff --git a/changelog/12444.bugfix.rst b/changelog/12444.bugfix.rst new file mode 100644 index 000000000..16b169336 --- /dev/null +++ b/changelog/12444.bugfix.rst @@ -0,0 +1 @@ +Fix approx wrong error description, when using to compare 2 dicts which are not in the same order - printing all values as wrong. diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 9b17e5cb7..dd0209cb0 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -255,9 +255,8 @@ class ApproxMapping(ApproxBase): max_abs_diff = -math.inf max_rel_diff = -math.inf different_ids = [] - for (approx_key, approx_value), other_value in zip( - approx_side_as_map.items(), other_side.values() - ): + for approx_key, approx_value in approx_side_as_map.items(): + other_value = other_side[approx_key] if approx_value != other_value: if approx_value.expected is not None and other_value is not None: max_abs_diff = max(