|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- import unittest
- from city_functions import city_detail
- class CityTestCase(unittest.TestCase):
- """测试city_functions.py."""
- def test_city_detail(self):
- """是否可以处理河南,中国这样的字串"""
- detail = city_detail("santiago", "chile", "500000")
- self.assertEqual(detail, "Santiago, Chile, -500000")
- if __name__ == "__main__":
- unittest.main()
复制代码- def city_detail(city, country, population):
- return f"{city}, {country}, -{population}".title()
复制代码
运行之后报错- Traceback (most recent call last):
- File "F:\anaconda3\envs\第11章\lib\unittest\loader.py", line 153, in loadTestsFromName
- module = __import__(module_name)
- ModuleNotFoundError: No module named 'test.cities'
复制代码
报错的位置是系统里的文件,各位大佬,这种情况该怎么办?
|
|