Skip to content

Commit 4a0f710

Browse files
fix: format
1 parent 89edc53 commit 4a0f710

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/_pytest/_io/pprint.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,7 @@ def __init__(
6262
indent: int = 4,
6363
width: int = 80,
6464
depth: int | None = None,
65-
<<<<<<< HEAD
6665
sort_dicts: bool = False,
67-
=======
68-
sort_dicts: bool = True,
69-
>>>>>>> 004825824a612277d452488b01af76ce33bb85d9
7066
) -> None:
7167
"""Handle pretty printing operations onto a stream using a set of
7268
configured parameters.
@@ -79,6 +75,9 @@ def __init__(
7975
8076
depth
8177
The maximum depth to print out nested structures.
78+
79+
sort_dicts
80+
If true, dict keys are sorted.
8281
8382
sort_dicts
8483
If true, dict keys are sorted.
@@ -94,6 +93,7 @@ def __init__(
9493
self._indent_per_level = indent
9594
self._width = width
9695
self._sort_dicts = sort_dicts
96+
self._sort_dicts = sort_dicts
9797

9898
def pformat(self, object: Any) -> str:
9999
sio = _StringIO()
@@ -171,6 +171,10 @@ def _pprint_dict(
171171
) -> None:
172172
write = stream.write
173173
write("{")
174+
if self._sort_dicts:
175+
items = sorted(object.items(), key=_safe_tuple)
176+
else:
177+
items = object.items()
174178
if self._sort_dicts:
175179
items = sorted(object.items(), key=_safe_tuple)
176180
else:
@@ -620,6 +624,11 @@ def _safe_repr(
620624
components: list[str] = []
621625
append = components.append
622626
level += 1
627+
if self._sort_dicts:
628+
items = sorted(object.items(), key=_safe_tuple)
629+
else:
630+
items = object.items()
631+
for k, v in items:
623632
if self._sort_dicts:
624633
items = sorted(object.items(), key=_safe_tuple)
625634
else:

0 commit comments

Comments
 (0)