File: test_wordlist.py

package info (click to toggle)
python-wordaxe 0.3.2-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 1,228 kB
  • ctags: 786
  • sloc: python: 9,814; makefile: 5
file content (74 lines) | stat: -rw-r--r-- 2,390 bytes parent folder | download
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import unittest


__author__ = "Henning von Bargen"


if False:
    # We know that PyHnj does not hyphenate many German words as it should,
    # so leave this test out
    class WordlistTestCase(unittest.TestCase):
        "Test hyphenation using a word list with PyHnj."

        def i_test(self, hy):
            errs = []
            def error(msg, *args):
                errs.append(msg % args)
            hy.testWordList("test_wordlist.txt", "utf8", error)
            errors = "\n".join(errs)
            #self.assertEqual (errors, "")
            if errors:
                print "WordlistTestCase: The following words are not hyphenated as they should:"
                print errors

        def test(self):
            from wordaxe.PyHnjHyphenator import PyHnjHyphenator
            hnjHyphenator = PyHnjHyphenator('de_DE', 4, purePython=1)
            self.i_test(hnjHyphenator)


class DCWWordlistTestCase(unittest.TestCase):
    "Test hyphenation using a word list with DCW."

    def i_test(self, hy):
        errs = []
        def error(msg, *args):
            errs.append(msg % args)
        hy.testWordList("test_wordlist.txt", "utf8", error)
        errors = "\n".join(errs)
        #self.assertEqual (errors, "")
        if errors:
            print "DCWWordlistTestCase: The following words are not hyphenated as they should:"
            print errors

    def test(self):
        from wordaxe.DCWHyphenator import DCWHyphenator
        dcwHyphenator = DCWHyphenator('DE', 4)
        self.i_test(dcwHyphenator)

class PyHyphenWordlistTestCase(unittest.TestCase):
    "Test hyphenation using a word list with PyHyphen."

    def i_test(self, hy):
        errs = []
        def error(msg, *args):
            errs.append(msg % args)
        hy.testWordList("test_wordlist.txt", "utf8", error)
        errors = "\n".join(errs)
        #self.assertEqual (errors, "")
        if errors:
            print "PyHyphenWordlistTestCase: The following words are not hyphenated as they should:"
            print errors

    def test(self):
        from wordaxe.plugins.PyHyphenHyphenator import PyHyphenHyphenator
        hyphenator = PyHyphenHyphenator('de_DE', 4)
        self.i_test(hyphenator)

if __name__ == "__main__":
    unittest.main()