无法从Jenkins运行nosetests,错误:ImportError:没有名为的模块

2024-04-24 16:33:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我想从Jenkins本地运行Python测试用例。我有一个shell脚本,在我的Mac终端上可以很好地执行:

$ cat script.sh 
#!/bin/bash
appium &
sleep 10s
cd /Users/<user>/eddie-qa/automation
nosetests -s --tc-file=/Users/<user>/eddie-qa/automation/mobile_automation/configs/local_config_android_galaxy_6_0.py --tc-format python mobile_automation.tests.login_logout.tests_login_logout:TestLogin.test_05_incorrect_username_login

但当我用同样的脚本从詹金斯那里运行时:

Jenkins build config

它返回错误: ImportError: No module named mobile_automation.configs.devices

我的文件local_config_android_galaxy_6_0.py以以下行开头:

from mobile_automation.configs.devices import desired_caps global config config = {}

devices.py中,代码以:

^{pr2}$

我不知道为什么会失败。 如果我不使用--tc-file=/Users/<user>/eddie-qa/automation/mobile_automation/configs/local_config_android_galaxy_6_0.py执行脚本,那么它就可以工作了。在

项目结构:

Python structure

如果有人有主意请告诉我。在

附加信息:

  • Nosetests:/usr/local/bin/Nosetests
  • 附录:v1.7.2
  • 詹金斯:跑在http://localhost:8080/
  • Mac:High Sierra,第10.13.3节

Tags: py脚本configlocalloginmobileqagalaxy