示例工程 05-iteration-comprehensions

05-iteration-comprehensions/04-groupby-needs-sort/test_groupby_needs_sort.py

python · 0.4 KB

"""test_groupby_needs_sort.py"""
 
from __future__ import annotations
 
from groupby_needs_sort import groups_sorted, groups_unsorted
 
 
def test_unsorted_splits_groups() -> None:
    assert groups_unsorted() == [("b", [1]), ("a", [1]), ("b", [2]), ("a", [2])]
 
 
def test_sorted_merges_groups() -> None:
    assert groups_sorted() == [("a", [1, 2]), ("b", [1, 2])]