When using the command line to run the case, it prompts python.exe: Error while finding module specification for'testcase_1.Test'...

created at 10-17-2021 views: 1

file path

file path

input the command

D:\demo>python -m unittest unittest_1/testcase_1.Test

Result prompt

ModuleNotFoundError: No module named'unittest_1/testcase_1',

Details as shown

python -m unittest unittest_1/testcase_1.Test

Solution:

Enter the unittest_1 path and enter the command python -m unittest testcase_1.Test

python -m unittest testcase_1.Test

Enter the command python -m testcase_1.Test

Result prompt

Error while finding module specification for'testcase_1.Test' (ModuleNotFoundError: __path__ attribute not found on'testcase_1' while trying to find'testcase_1.Test')

Solution:

The command statement is wrong, the execution command is python -m unittest [module name]. Class name.

Please log in to leave a comment.