def test_first_last_middle_name(self):
     """Do names like 'Wolfgang Amadeus Mozart' work?"""
     formatted_name = get_formatted_name('wolfgang', 'mozart', 'amadeus')
     self.assertEqual(formatted_name, 'Wolfgang Amadeus Mozart')
 def test_first_last_name(self):
     """Do names like 'Janice Joplin" work?"""
     formatted_name = get_formatted_name('janis', 'joplin')
     self.assertEqual(formatted_name, 'Janis Joplin')
예제 #3
0
 def test_first_last_middle_name(self):
     """Do names like 'Janis Mindoza Joplin' work?"""
     formatted_name = get_formatted_name('janis', 'joplin', 'mindoza')
     self.assertEqual(formatted_name, 'Janis Mindoza Joplin')
def get_formatted_name(first, last):
    """Generate a neatly formatted name"""
    full_name = first + ' ' + last
    return full_name.title()


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 + '.')

# Unit test is for each units. Unit case is for whole testing of your program.
# We use class to test your defined functions. In class put "unittest.TestCase" which means hey this class is made for testing!
import unittest
from names import get_formatted_name


class NamesTestCase(unittest.TestCase):
    def test_first_last_name(self):
        """Do names like 'Janice Joplin" work?"""
        formatted_name = get_formatted_name('janis', 'joplin')
        self.assertEqual(formatted_name, 'Janis Joplin')

    def test_first_last_middle_name(self):
예제 #5
0
 def test_last_first_name(self):
     self.assertEquals('Janis Joplin',
                       get_formatted_name('Janis', 'Joplin'))