This is the code I typed from the book, and when I run it, the compiler displays “No tests were found”. What is the reason for this? How to solve it?
names.py
from name_function import get_formatted_name
print("Enter 'q' to quit")
while True:
first = input("Enter your first name: ")
if first == 'q':
break
last = input("Enter your last name: ")
if last == 'q':
break
formatted_name = get_formatted_name(first, last)
print("\tNeatly formatted name: " + formatted_name + '.')
name_function.py
def get_formatted_name(first, last):
"""Generate well-organized full names"""
full_name = first + ' ' + last
return full_name.title()
test_name_function.py
import unittest
from name_function import get_formatted_name
class NameTestCase(unittest.TestCase):
"""Test name_function.py"""
def test_first_last_name(self):
"""Can it handle names like Janis Joplin correctly"""
formatted_name = get_formatted_name('janis', 'joplin')
self.assertEqual(formatted_name, 'Janis Joplin')
unittest.main()