ImportError: Failed to import test module: 2

1.在进行unittest测试时,运行报错如下 

导入import unittest 包 ,创建的文件名字得是 Test 开头的,不然报如下的错误

我的文件名字是 2.unittest简单实用-first_test会出现报错ImportError: Failed to import test module: 2这里面的2就是我命名里面的 

解决办法:将文件夹改为testproject,文件改为了first_test就可以了

ImportError: Failed to import test module: 2_第1张图片

ImportError: Failed to import test module: 2_第2张图片

 改为以下

ImportError: Failed to import test module: 2_第3张图片

运行

 ImportError: Failed to import test module: 2_第4张图片

2.当运行出现ModuleNotFoundError: No module named 'selenium'这样的报错的时候,需要设置以下python路径,查看以下是否存在selenium

ImportError: Failed to import test module: 2_第5张图片 如下步骤操作就可以解决

ImportError: Failed to import test module: 2_第6张图片ImportError: Failed to import test module: 2_第7张图片

ImportError: Failed to import test module: 2_第8张图片 ImportError: Failed to import test module: 2_第9张图片

 

你可能感兴趣的:(ImportError: Failed to import test module: 2)