Files
python-learning/exercises/01-core/02-collections/test_collections_ex.py
T

19 lines
548 B
Python

from collections_ex import first_and_last, unique_sorted, word_counts
def test_unique_sorted() -> None:
assert unique_sorted([3, 1, 2, 3, 1]) == [1, 2, 3]
assert unique_sorted([]) == []
def test_word_counts() -> None:
counts = word_counts("Python python is great and PYTHON works")
assert counts["python"] == 3
assert counts["is"] == 1
def test_first_and_last() -> None:
assert first_and_last([]) is None
assert first_and_last(["only"]) == ("only", "only")
assert first_and_last(["a", "b", "c"]) == ("a", "c")