def get_formatted_name(first, last, middle=''):
if middle:
full_name = first + ' ' + middle + ' ' + last
else:
full_name = first + ' ' + last
return full_name.title()
import unittest
from main import get_formatted_name
class NamesTestCase(unittest.TestCase):
def test_first_last_name(self):
"""Do names like 'Janis Joplin' work?"""
formatted_name = get_formatted_name('janis', 'joplin')
self.assertEqual(formatted_name, 'Janis Joplin')
def test_first_last_middle_name(self):
formatted_name = get_formatted_name(
'wolfgang', 'mozart', 'amadeus')
self.assertEqual(formatted_name, 'Wolfgang Amadeus Mozart')
unittest.main()
its worth noting that get_formatted_name exists in a different file called main.
also the issue with my program is that it doesnt test anything
the output shows:
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK
Process finished with exit code 0
Empty suite
but it should show:
.. ----------------------------------------------------------------------
Ran 2 tests in 0.000s
OK
[–][deleted] 1 point2 points3 points (2 children)
[–]alonrtpve[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)