Zanurkuj w Pythonie/Źródła/soundextest.py

#-*- coding: utf-8

u"""Testy jednostkowe dla soundex.py

Ten program jest częścią "Dive Into Python", wolnej książki o Pythonie dla doświadczonych
programistów. Najnowszą wersję możesz znaleźć tu: http://diveintopython.org/.
"""

__author__ = "Mark Pilgrim (mark@diveintopython.org)"
__version__ = "$Revision: 1.1 $"
__date__ = "$Date: 2004/05/06 17:18:17 $"
__copyright__ = "Copyright (c) 2004 Mark Pilgrim"
__license__ = "Python"

import soundex
import unittest

class KnownValues(unittest.TestCase):
    knownValues = (('', '0000'),
		   ('Woo', 'W000'),
		   ('Pilgrim', 'P426'),
		   ('Radiohead', 'R330'),
		   ('Flingjingwaller', 'F452'),
		   ('Euler', 'E460'),
		   ('Ellery', 'E460'),
		   ('Gauss', 'G200'),
		   ('Ghosh', 'G200'),
		   ('Hilbert', 'H416'),
		   ('Heilbronn', 'H416'),
		   ('Knuth', 'K530'),
		   ('Kant', 'K530'),
		   ('Lukasiewicz', 'L222'),
		   ('Lissajous', 'L222')
                  )
    
    def testKnownValues(self):
        """soundex should give known result with known input"""
        for name, result in self.knownValues:
	    self.assertEqual(soundex.soundex(name), result)

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