import unittest
from city_functions import get_city_country
class NameTestCase(unittest.TestCase):
'''测试city_function.py'''
def test_city_country(self):
'''能够正确处理像Santiago, Chile这样格式的输出结果吗?'''
formatted_name = get_city_country('santiago', 'chile')
self.assertEqual(formatted_name,'Santiago, Chile')
if __name__ == '__main__':
unittest.main()
> 这里是引用模块city_function.py文件
> def get_city_country(city,country):
'''生成格式为city,country的字符串'''
full_name = f'{city}, {country}'
return full_name.title()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)