django 单元测试出现ModuleNotFoundError: No module named 'xxx.traceapp'错误
具体错误如下:
======================================================================
ERROR: xxx.xxapp (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: xxx.xxapp
Traceback (most recent call last):
File "/usr/local/lib/python3.8/unittest/loader.py", line 470, in _find_test_path
package = self._get_module_from_name(name)
File "/usr/local/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
ModuleNotFoundError: No module named 'xxx.xxapp'
======================================================================
ERROR: xxx.txxapp (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: xxx.txxapp
Traceback (most recent call last):
File "/usr/local/lib/python3.8/unittest/loader.py", line 470, in _find_test_path
package = self._get_module_from_name(name)
File "/usr/local/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
ModuleNotFoundError: No module named 'xxx.txxapp'
解决:
查看manage.pyc下面是否有目录索引文件__init__.py, 如果有尝试删除。