forked from bermi/Python-Inflector
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.py
129 lines (99 loc) · 3.85 KB
/
tests.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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2006 Bermi Ferrer Martinez
#
# bermi a-t bermilabs - com
#
import unittest
from inflector import Inflector, English
class EnglishInflectorTestCase(unittest.TestCase):
singular_to_plural = {
"search" : "searches",
"switch" : "switches",
"fix" : "fixes",
"box" : "boxes",
"process" : "processes",
"address" : "addresses",
"case" : "cases",
"stack" : "stacks",
"wish" : "wishes",
"fish" : "fish",
"category" : "categories",
"query" : "queries",
"ability" : "abilities",
"agency" : "agencies",
"movie" : "movies",
"archive" : "archives",
"index" : "indices",
"wife" : "wives",
"safe" : "saves",
"half" : "halves",
"move" : "moves",
"salesperson" : "salespeople",
"person" : "people",
"spokesman" : "spokesmen",
"man" : "men",
"woman" : "women",
"basis" : "bases",
"diagnosis" : "diagnoses",
"datum" : "data",
"medium" : "media",
"analysis" : "analyses",
"node_child" : "node_children",
"child" : "children",
"experience" : "experiences",
"day" : "days",
"comment" : "comments",
"foobar" : "foobars",
"newsletter" : "newsletters",
"old_news" : "old_news",
"news" : "news",
"series" : "series",
"species" : "species",
"quiz" : "quizzes",
"perspective" : "perspectives",
"ox" : "oxen",
"photo" : "photos",
"buffalo" : "buffaloes",
"tomato" : "tomatoes",
"dwarf" : "dwarves",
"elf" : "elves",
"information" : "information",
"equipment" : "equipment",
"bus" : "buses",
"status" : "statuses",
"mouse" : "mice",
"louse" : "lice",
"house" : "houses",
"octopus" : "octopi",
"virus" : "viri",
"alias" : "aliases",
"portfolio" : "portfolios",
"vertex" : "vertices",
"matrix" : "matrices",
"axis" : "axes",
"testis" : "testes",
"crisis" : "crises",
"rice" : "rice",
"shoe" : "shoes",
"horse" : "horses",
"prize" : "prizes",
"edge" : "edges"
}
def setUp(self):
self.inflector = Inflector(English)
def tearDown(self):
self.inflector = None
def test_pluralize(self) :
for singular in self.singular_to_plural.keys() :
assert self.inflector.pluralize(singular) == self.singular_to_plural[singular], \
'English Inlector pluralize(%s) should produce "%s" and NOT "%s"' % (singular, self.singular_to_plural[singular], self.inflector.pluralize(singular))
def test_singularize(self) :
for singular in self.singular_to_plural.keys() :
assert self.inflector.singularize(self.singular_to_plural[singular]) == singular, \
'English Inlector singularize(%s) should produce "%s" and NOT "%s"' % (self.singular_to_plural[singular], singular, self.inflector.singularize(self.singular_to_plural[singular]))
InflectorTestSuite = unittest.TestSuite()
InflectorTestSuite.addTest(EnglishInflectorTestCase("test_pluralize"))
InflectorTestSuite.addTest(EnglishInflectorTestCase("test_singularize"))
runner = unittest.TextTestRunner()
runner.run(InflectorTestSuite)