现在我使用pytest运行Python 3单元测试,以下是我的代码:
from dolphin.biz.notifier.dingtalk.dingtalk_impl import DingtalkImpl
class TestDingtalk:
def test_send_message(self):
dingtalkImpl = DingtalkImpl()
dingtalkImpl.send_dingtalk_notify_message(1)
然后我运行这个命令来执行路径/home/dolphin/Documents/GitHub/pydolphin/test/cert/dingtalk
中的单元测试:
pytest test_dingtalk.py
但显示此错误(仅在单元测试中发生):
ImportError while importing test module '/home/dolphin/Documents/GitHub/pydolphin/test/cert/dingtalk/test_dingtalk.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/home/dolphin/anaconda3/envs/pydolphin/lib/python3.9/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
test_dingtalk.py:1: in <module>
from dolphin.biz.notifier.dingtalk.dingtalk_impl import DingtalkImpl
E ModuleNotFoundError: No module named 'dolphin'
=========================================================================================== short test summary info ============================================================================================
ERROR test_dingtalk.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=============================================================================================== 1 error in 0.05s ===============================================================================================
我的项目结构如下:
我尝试过像这样指定python路径:
set PYTHONPATH=/home/dolphin/Documents/GitHub/pydolphin && pytest test_dingtalk.py
仍然不起作用,我该怎么做才能使它起作用?我也试过这样做:
pytest ./test/cert/dingtalk/test_dingtalk.py
目前没有回答
相关问题 更多 >
编程相关推荐