pytest报错 make sure your test modules/packages have valid Python names.

Posted walkerpython

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pytest报错 make sure your test modules/packages have valid Python names.相关的知识,希望对你有一定的参考价值。

ImportError while importing test module ‘D:PythonPycharmProjectsPYDEMOTestCasemain.py‘.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
TestCase est_suite.py:6: in <module>
    from TestCase import test_http_request
E   ModuleNotFoundError: No module named ‘TestCase‘
————————————————
版权声明:本文为CSDN博主「海染蓝」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/nember_1/java/article/details/105913250

方法 1 在要执行pytest 的根目录新建   conftest.py文件;文件内容

import os

import sys

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ‘..‘)))


方法2 pytet 在执行测试 test case 目录下每个目录都包含 __init__.py文件 ;
在项目的跟目录执行

以上是关于pytest报错 make sure your test modules/packages have valid Python names.的主要内容,如果未能解决你的问题,请参考以下文章

Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" direct

Error writing temporary file. Make sure your temp folder is valid

SEVERE: Unable to join multicast group, make sure your system has multicasting enabled.

ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHO

Android error “Could not get BatchedBridge, make sure your bundle is packaged properly” on start of

解决failed to execute WindowsPath(‘dot‘), make sure the Graphviz executables are on your systems‘ PATH