File: test_lists.py

package info (click to toggle)
python-babel 2.8.0%2Bdfsg.1-7
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 194,932 kB
  • sloc: xml: 2,069,184; python: 12,072; makefile: 197; sh: 36
file content (21 lines) | stat: -rw-r--r-- 728 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# coding=utf-8
import pytest

from babel import lists


def test_format_list():
    for list, locale, expected in [
        ([], 'en', ''),
        ([u'string'], 'en', u'string'),
        (['string1', 'string2'], 'en', u'string1 and string2'),
        (['string1', 'string2', 'string3'], 'en', u'string1, string2, and string3'),
        (['string1', 'string2', 'string3'], 'zh', u'string1、string2和string3'),
        (['string1', 'string2', 'string3', 'string4'], 'ne', u'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')