在 UI 自动化框架工程目录下执行pytest时报错如下:

_________________________________________________ ERROR collecting test_cases/test_filming_and_upload_page/test_filming_page.py __________________________________________________
ImportError while importing test module '/Users/xxx/Projects/Python/py_uiautomator2/test_cases/test_filming_and_upload_page/test_filming_page.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
test_cases/test_filming_and_upload_page/test_filming_page.py:9: in <module>
    from common.app_engine import AppEngine
E   ModuleNotFoundError: No module named 'common'

工程结构如下:

test_filming_page.py 的引用代码如下:

在 PyCharm 中右键直接 run 文件 test_filming_page.py 没有问题,而在/Users/xxx/Projects/Python/py_uiautomator2/目录下,直接执行pytest时就会报错,不知道怎么回事呢?有人遇到过执行pytest找不到包引用的情况吗?


↙↙↙阅读原文可查看相关链接,并与作者交流