Python 版本 3.6
\n我有以下文件夹结构
\n.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 main.py\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 tests/\n| \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 test_Car.py\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 automobiles/\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 Car.py\nRun Code Online (Sandbox Code Playgroud)\n我的程序.py
\nfrom automobiles.Car import Car\n\np = Car("Grey Sedan")\nprint(p.descriptive_name())\nRun Code Online (Sandbox Code Playgroud)\n卡比
\nclass Car():\n description = "Default"\n \n def __init__(self, message):\n self.description = message\n\n def descriptive_name(self):\n return self.description\nRun Code Online (Sandbox Code Playgroud)\ntest_Car.py
\nfrom automobiles.Car import Car\n\ndef test_descriptive_name():\n input_string = "Blue Hatchback"\n p = Car(input_string)\n assert(p.descriptive_name() == input_string)\nRun Code Online (Sandbox Code Playgroud)\n运行pytest时时,出现以下错误-
\nTraceback:\n..\\..\\..\\AppData\\Local\\Programs\\Python\\Python36\\lib\\importlib\\__init__.py:126: in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\ntests\\test_Car.py:2: in <module>\n from automobiles.Car import Car\nE ModuleNotFoundError: …Run Code Online (Sandbox Code Playgroud)