⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pluraltest6.py

📁 Dive into Python 中文版
💻 PY
字号:
"""Unit test for plural6.pyThis program is part of "Dive Into Python", a free Python book forexperienced programmers.  Visit http://diveintopython.org/ for thelatest version."""__author__ = "Mark Pilgrim (mark@diveintopython.org)"__version__ = "$Revision: 1.1 $"__date__ = "$Date: 2004/03/17 14:34:40 $"__copyright__ = "Copyright (c) 2004 Mark Pilgrim"__license__ = "Python"from plural6 import pluralimport unittest, newclass 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',             }for noun, correctPlural in KnownValues.nouns.items():    testMethod = lambda self: KnownValues.failUnlessEqual(self, plural(noun), correctPlural)    testMethod.__doc__ = "%s --> %s" % (noun, correctPlural)    instanceMethod = new.instancemethod(testMethod, None, KnownValues)    setattr(KnownValues, "test_%s" % noun, instanceMethod)if __name__ == "__main__":    unittest.main()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -