File: test_lists.py

package info (click to toggle)
python-babel 2.6.0%2Bdfsg.1-1%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 164,640 kB
  • sloc: xml: 1,848,178; python: 11,849; makefile: 213; sh: 44
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')