forked from mozillazg/python-pinyin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_cmd.py
35 lines (27 loc) · 1023 Bytes
/
test_cmd.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from pypinyin.runner import get_parser
def test_default():
options = get_parser().parse_args(['你好'])
assert options.func == 'pinyin'
assert options.style == 'zh4ao'
assert options.separator == '-'
assert not options.heteronym
assert options.hans == '你好'
assert options.errors == 'default'
def test_custom():
options = get_parser().parse_args(['--func', 'slug',
'--style', 'zhao',
'--separator', ' ',
'--errors', 'ignore',
'--heteronym', '你好啊'])
assert options.func == 'slug'
assert options.style == 'zhao'
assert options.separator == ' '
assert options.errors == 'ignore'
assert options.heteronym
assert options.hans == '你好啊'
if __name__ == '__main__':
import pytest
pytest.cmdline.main()