Esempio n. 1
0
 def test_first_last_middle_name(self):
     """能够正确地处理像Wolfgang Amadeus Mozart正阳的姓名吗?"""
     formatted_name = get_formatted_name('wolfgang', 'mozart', 'amadeus')
     self.assertEqual(formatted_name, 'Wolfgang Amadeus Mozart')
Esempio n. 2
0
    """Generate a neatly formatted full name."""
    full_name = first + ' ' + last
    return  full_name.title()

from chapter11 import get_formatted_name

print("Enter 'q' at any time to quit.")
while True:
    first = input("\nPlease give me a first name: ")
    if first == 'q':
        break
    last = input("Please give me a last name: ")
    if last == 'q':
        break

    formatted_name = get_formatted_name(first, last)
    print("\tNeatly formatted name: " + formatted_name + '.')

#可通过的测试
import unittest
from chapter11 import get_formatted_name

class NamesTestCase(unittest.TestCase):
    """测试name_funciton.py"""

    def test_first_name(self):
        """能够正确地处理像Janis Joplin这样的名字吗?"""
        formatted_name = get_formatted_name('janis', 'joplin')
        self.assertEuqal(formatted_name, 'Janis Joplin')

unittest.main()
Esempio n. 3
0
 def test_first_name(self):
     """能够正确地处理像Janis Joplin这样的姓名吗?"""
     formatted_name = get_formatted_name('janis', 'joplin')
     self.assertEqual(formatted_name, 'Janis Joplin')
Esempio n. 4
0
 def test_get_formatted_name(self):
     formatted_name = get_formatted_name('dfd', 'bbb')
     self.assertEqual(formatted_name, 'Dfd Bbb')