Remove Python 2-only workaround
This commit is contained in:
parent
177af032d2
commit
d8fa434d39
|
@ -244,17 +244,9 @@ def _compare_eq_iterable(left, right, verbose=0):
|
||||||
# dynamic import to speedup pytest
|
# dynamic import to speedup pytest
|
||||||
import difflib
|
import difflib
|
||||||
|
|
||||||
try:
|
left_formatting = pprint.pformat(left).splitlines()
|
||||||
left_formatting = pprint.pformat(left).splitlines()
|
right_formatting = pprint.pformat(right).splitlines()
|
||||||
right_formatting = pprint.pformat(right).splitlines()
|
explanation = ["Full diff:"]
|
||||||
explanation = ["Full diff:"]
|
|
||||||
except Exception:
|
|
||||||
# hack: PrettyPrinter.pformat() in python 2 fails when formatting items that can't be sorted(), ie, calling
|
|
||||||
# sorted() on a list would raise. See issue #718.
|
|
||||||
# As a workaround, the full diff is generated by using the repr() string of each item of each container.
|
|
||||||
left_formatting = sorted(repr(x) for x in left)
|
|
||||||
right_formatting = sorted(repr(x) for x in right)
|
|
||||||
explanation = ["Full diff (fallback to calling repr on each item):"]
|
|
||||||
explanation.extend(
|
explanation.extend(
|
||||||
line.strip() for line in difflib.ndiff(left_formatting, right_formatting)
|
line.strip() for line in difflib.ndiff(left_formatting, right_formatting)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue