执行UI自动化测试用例时发生的问题
/usr/local/bin/python3.11 /Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm/_jb_pytest_runner.py --path /Users/kwai1/kwaishopuiautotest/test_case/demo/test_my_first_demo.py
Testing started at 16:05 ...
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/py/_vendored_packages/apipkg/__init__.py", line 145, in __makeattr
modpath, attrname = self.__map__[name]
~~~~~~~~~~~~^^^^^^
KeyError: '__spec__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm/_jb_pytest_runner.py", line 5, in
import pytest
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pytest/__init__.py", line 5, in
from _pytest.assertion import register_assert_rewrite
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/_pytest/assertion/__init__.py", line 9, in
from _pytest.assertion import rewrite
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/_pytest/assertion/rewrite.py", line 34, in
from _pytest.assertion import util
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/_pytest/assertion/util.py", line 13, in
import _pytest._code
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/_pytest/_code/__init__.py", line 2, in
from .code import Code
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/_pytest/_code/code.py", line 54, in
class Code:
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/_pytest/_code/code.py", line 81, in Code
def path(self) -> Union[py.path.local, str]:
^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/py/_vendored_packages/apipkg/__init__.py", line 152, in __makeattr
result = importobj(modpath, attrname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/py/_vendored_packages/apipkg/__init__.py", line 72, in importobj
module = __import__(modpath, None, None, ['__doc__'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "" , line 1178, in _find_and_load
File "" , line 1138, in _find_and_load_unlocked
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/py/_vendored_packages/apipkg/__init__.py", line 150, in __makeattr
raise AttributeError(name)
AttributeError: __spec__
进程已结束,退出代码1
空套件
试下在“文件”>;“设置”>;“工具”>;“Python集成工具”对话框中将“默认测试运行器”设置为Nosetests。如果已经尝试过使用非Nosetests运行程序(默认情况下,例如,Unittests似乎是默认配置),那么必须首先删除现有配置。为此,请转到“运行”>;“编辑配置”,在“Python tests”下会看到“Unittests in test_your_filename”。单击该按钮,然后单击要删除的框架顶部的红色“-”按钮。