-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_utility.py
42 lines (27 loc) · 1.16 KB
/
test_utility.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
36
37
38
39
40
import json
import pkgutil
from nose.tools import *
from cyr2phon import syllabify, strip_onset
# tests for syllabify()
words_to_syllabify = _lexical_data = json.loads(
pkgutil.get_data(__package__, 'words_to_syllabify.json').decode('utf-8')) # file inside package
def test_syllabify_word():
for word in words_to_syllabify:
fn = lambda: syllabify(word)
fn.description = "cyr2phon.tests.test_utility.test_syllabify_word with {}".format(word)
yield fn
def check_syllabify_word(word):
assert_equal(syllabify(word), [syllable for syllable in words_to_syllabify[word].split("-")])
#tests for strip_onset()
def test_strip_onset_bA(): # open masculine with onset singular
expected = ['BA']
assert_equal(strip_onset(['BA']), expected)
def test_strip_onset_sna(): # open masculine with onset cluster
expected = ['nA']
assert_equal(strip_onset(['snA']), expected)
def test_strip_onset_proch(): # closed masculine with onset
expected = ['OČ']
assert_equal(strip_onset(['prOČ']), expected)
def test_strip_onset_babA(): # feminine with onset
expected = ['A', 'Vil']
assert_equal(strip_onset(['prA', 'Vil']), expected)