/usr/share/doc/diveintopython-zh/examples/pluraltest.py is in diveintopython-zh 5.4b-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | """Unit test for plural.py
This program is part of "Dive Into Python", a free Python book for
experienced programmers. Visit http://diveintopython.org/ for the
latest version.
"""
__author__ = "Mark Pilgrim (mark@diveintopython.org)"
__version__ = "$Revision: 1.2 $"
__date__ = "$Date: 2004/03/17 14:34:40 $"
__copyright__ = "Copyright (c) 2004 Mark Pilgrim"
__license__ = "Python"
from plural import plural
import unittest, new
class KnownValues(unittest.TestCase):
nouns = {'bass': 'basses',
'bus': 'buses',
'walrus': 'walruses',
'box': 'boxes',
'fax': 'faxes',
'suffix': 'suffixes',
'mailbox': 'mailboxes',
'buzz': 'buzzes',
'waltz': 'waltzes',
'coach': 'coaches',
'glitch': 'glitches',
'rash': 'rashes',
'watch': 'watches',
'cheetah': 'cheetahs',
'cough': 'coughs',
'utility': 'utilities',
'vacancy': 'vacancies',
'soliloquy': 'soliloquies',
'boy': 'boys',
'day': 'days',
'computer': 'computers',
'rock': 'rocks',
'paper': 'papers',
'mouse': 'mice',
'louse': 'lice',
'child': 'children',
'foot': 'feet',
'booth': 'booths',
'tooth': 'teeth',
'leaf': 'leaves',
'loaf': 'loaves',
'thesis': 'theses',
'man': 'men',
'mailman': 'mailmen',
'knife': 'knives',
'wife': 'wives',
'tableau': 'tableaux',
'elf': 'elves',
'shelf': 'shelves',
'sheep': 'sheep',
'deer': 'deer',
'fish': 'fish',
'moose': 'moose',
'aircraft': 'aircraft',
'series': 'series',
'haiku': 'haiku',
'delf': 'delfs',
'pelf': 'pelfs',
'human': 'humans',
'roman': 'romans',
'lowlife': 'lowlifes',
}
for noun, pluralnoun in KnownValues.nouns.items():
func = lambda self, noun=noun, pluralnoun=pluralnoun: \
KnownValues.failUnlessEqual(self, plural(noun), pluralnoun)
func.__doc__ = "%s --> %s" % (noun, pluralnoun)
instanceMethod = new.instancemethod(func, None, KnownValues)
setattr(KnownValues, "test_%s" % noun, instanceMethod)
if __name__ == "__main__":
unittest.main()
|