forked from staticdev/human-readable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_lists.py
59 lines (50 loc) · 1.73 KB
/
test_lists.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""Tests for listing humanization."""
from __future__ import annotations
import pytest
import human_readable.lists as lists
@pytest.mark.parametrize(
"params, expected",
[
(([], ","), ""), # empty list
((["jorbas"], ","), "jorbas"), # one element
((["jorbas", "maria"], ","), "jorbas, maria"), # two elements
((["jorbas", "maria"], ""), "jorbas maria"), # empty separator
],
)
def test_listing(params: tuple[list[str], str], expected: str) -> None:
"""Listing with separator."""
assert lists.listing(*params) == expected
@pytest.mark.parametrize(
"params, expected",
[
(([], ";", "or"), ""), # empty list
((["jorbas"], ";", "or"), "jorbas"), # one element
((["jorbas", "maria"], ";", "or"), "jorbas or maria"), # two elements
(
(["jorbas", "maria", "gustavo"], ";", "or"),
"jorbas; maria or gustavo",
), # three elements
],
)
def test_listing_with_conjunction(
params: tuple[list[str], str, str], expected: str
) -> None:
"""Listing with separator and conjunction."""
assert lists.listing(*params) == expected
@pytest.mark.parametrize(
"params, expected",
[
(([], ";", "or"), ""), # empty list
((["jorbas"], ";", "or"), "jorbas"), # one element
((["jorbas", "maria"], ";", "or"), "jorbas or maria"), # two elements
(
(["jorbas", "maria", "gustavo"], ";", "or"),
"jorbas; maria; or gustavo",
), # three elements
],
)
def test_listing_with_conjunction_oxford(
params: tuple[list[str], str, str], expected: str
) -> None:
"""Listing with separator and conjunction."""
assert lists.listing(*params, oxford=True) == expected