阿蔡呀 2023-02-07 16:24 采纳率: 0%
浏览 73
已结题

raise AttributeError(name) 空套件

执行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 <module>
    import pytest
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pytest/__init__.py", line 5, in <module>
    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 <module>
    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 <module>
    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 <module>
    import _pytest._code
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/_pytest/_code/__init__.py", line 2, in <module>
    from .code import Code
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/_pytest/_code/code.py", line 54, in <module>
    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 "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", 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

空套件

  • 写回答

2条回答 默认 最新

  • 元气少女缘结神 2023-02-07 16:46
    关注

    试下在“文件”>;“设置”>;“工具”>;“Python集成工具”对话框中将“默认测试运行器”设置为Nosetests。如果已经尝试过使用非Nosetests运行程序(默认情况下,例如,Unittests似乎是默认配置),那么必须首先删除现有配置。为此,请转到“运行”>;“编辑配置”,在“Python tests”下会看到“Unittests in test_your_filename”。单击该按钮,然后单击要删除的框架顶部的红色“-”按钮。

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 2月21日
  • 创建了问题 2月7日

悬赏问题

  • ¥15 onlyoffice编辑完后立即下载,下载的不是最新编辑的文档
  • ¥15 求caverdock使用教程
  • ¥15 Coze智能助手搭建过程中的问题请教
  • ¥15 12864只亮屏 不显示汉字
  • ¥20 三极管1000倍放大电路
  • ¥15 vscode报错如何解决
  • ¥15 前端vue CryptoJS Aes CBC加密后端java解密
  • ¥15 python随机森林对两个excel表格读取,shap报错
  • ¥15 基于STM32心率血氧监测(OLED显示)相关代码运行成功后烧录成功OLED显示屏不显示的原因是什么
  • ¥100 X轴为分离变量(因子变量),如何控制X轴每个分类变量的长度。