city_functions.py
def get_city_country(city,country,population=''):
if population:
city_country = city + ' ' + country + '--' + population
else:
city_country = city + ' ' + country
return city_country.title()
get_city_country('yanan','china','population 130000000')
test_cities.py
import unittest
from city_functions import get_city_country
class CityCountry(unittest.TestCase):
def test_city_country(self):
formatted_name = get_city_country('yanan','china','population 130000000')
self.assertEqual(formatted_name,'Yanan China--Population 130000000')
def test_city_country_population(self):
formatted_name = get_city_country('yanan','china')
self.assertEqual(formatted_name,'Yanan China')