summaryrefslogtreecommitdiff
path: root/tests/test_lists.py
blob: ca9c6ab41a30e8cd69da49ff3488d5fcf0830b59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import pytest

from babel import lists


def test_format_list():
    for list, locale, expected in [
        ([], 'en', ''),
        (['string'], 'en', 'string'),
        (['string1', 'string2'], 'en', 'string1 and string2'),
        (['string1', 'string2', 'string3'], 'en', 'string1, string2, and string3'),
        (['string1', 'string2', 'string3'], 'zh', 'string1、string2和string3'),
        (['string1', 'string2', 'string3', 'string4'], 'ne', 'string1,string2, string3 र string4'),
    ]:
        assert lists.format_list(list, locale=locale) == expected


def test_format_list_error():
    with pytest.raises(ValueError):
        lists.format_list(['a', 'b', 'c'], style='orange', locale='en')