Skip to content

Commit

Permalink
Fix Black Formatting problems.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaakov Belch committed Aug 18, 2023
1 parent e2131b7 commit 82eb0d3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion msgpack_sorted/fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ def _pack(
self._pack(obj[i], nest_limit - 1)
return
if check(obj, dict):
_items = sorted(obj.items()) if self._sort_keys else obj.items()
_items = sorted(obj.items()) if self._sort_keys else obj.items()
return self._pack_map_pairs(len(obj), _items, nest_limit - 1)

if self._datetime and check(obj, _DateTime) and obj.tzinfo is not None:
Expand Down
3 changes: 2 additions & 1 deletion test/test_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,11 @@ def test_get_buffer():
expected = packb([1, 2], use_bin_type=True)
assert written == expected


def test_sort_keys(sizes=[3, 31, 127, 1023]):
for size in sizes:
keys = range(1, 1000000000, 1000000000 // size)
map1 = {k: k for k in keys}
map2 = {k: k for k in reversed(keys)}
assert packb(map1, sort_keys=False) != packb(map2, sort_keys=False)
assert packb(map1, sort_keys=True) == packb(map2, sort_keys=True)
assert packb(map1, sort_keys=True) == packb(map2, sort_keys=True)

0 comments on commit 82eb0d3

Please sign in to comment.