File: test_decode.py

package info (click to toggle)
faker 39.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,712 kB
  • sloc: python: 343,295; makefile: 183; sh: 20
file content (35 lines) | stat: -rw-r--r-- 825 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
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import pytest

from faker.decode import unidecode


@pytest.mark.parametrize(
    ("text", "result"),
    [
        (
            "Programmes de publicité - Solutions d'entreprise",
            "Programmes de publicite - Solutions d'entreprise",
        ),
        ("Транслитерирует и русский", "Transliteriruet i russkii"),
        ("kožušček", "kozuscek"),
        ("北亰", "Bei Jing "),
        ("ij", "ij"),
    ],
)
def test_transliterate(text, result):
    assert unidecode(text) == result


@pytest.mark.parametrize("code", range(128))
def test_7bit_purity(code):
    ch = chr(code)
    assert unidecode(ch) == ch


def test_7bit_text_purity():
    txt = "".join([chr(x) for x in range(128)])
    assert unidecode(txt) == txt


def test_out_of_bounds():
    assert unidecode("𐀀") == ""