遇见飞鱼 2021-09-03 15:34 采纳率: 100%
浏览 373
已结题

python3.9 + pytest 报错 “INTERNALERROR> Traceback (most recent call last):”看看这是什么问题引起的呢?

以下是脚本


import pytest

class TestFeng():

    def test_0001(self):
        print("test_0001")

    def test_0002(self):
        print("test_0002")

if __name__ == '__main__':
    pytest.main(['-s','testfengkong.py'])

报错信息
C:\Python\Python38\python.exe D:/Users/Administrator/PycharmProjects1/xianneng/testcase/testfengkong.py
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "C:\Python\Python38\lib\site-packages_pytest\main.py", line 265, in wrap_session
INTERNALERROR> config.do_configure()
INTERNALERROR> File "C:\Python\Python38\lib\site-packages_pytest\config_init
.py", line 982, in _do_configure
INTERNALERROR> self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR> File "C:\Python\Python38\lib\site-packages\pluggy_hooks.py", line 277, in call_historic
INTERNALERROR> res = self._hookexec(self.name, self.get_hookimpls(), kwargs, False)
INTERNALERROR> File "C:\Python\Python38\lib\site-packages\pluggy_manager.py", line 80, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "C:\Python\Python38\lib\site-packages\pluggy_callers.py", line 60, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "C:\Python\Python38\lib\site-packages\pluggy_result.py", line 60, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "C:\Python\Python38\lib\site-packages\pluggy_callers.py", line 39, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "C:\Python\Python38\lib\site-packages_pytest\logging.py", line 518, in pytest_configure
INTERNALERROR> config.pluginmanager.register(LoggingPlugin(config), "logging-plugin")
INTERNALERROR> File "C:\Python\Python38\lib\site-packages_pytest\logging.py", line 552, in init
INTERNALERROR> self.log_file_handler = FileHandler(log_file, mode="w", encoding="UTF-8")
INTERNALERROR> File "C:\Python\Python38\lib\logging_init
.py", line 1143, in init
INTERNALERROR> StreamHandler.init(self, self.open())
INTERNALERROR> File "C:\Python\Python38\lib\logging_init
.py", line 1172, in _open
INTERNALERROR> return open(self.baseFilename, self.mode, encoding=self.encoding)
INTERNALERROR> FileNotFoundError: [Errno 2] No such file or directory: '\\.\nul'

Process finished with exit code 0

img

img

  • 写回答

2条回答 默认 最新

  • 遇见飞鱼 2021-09-03 16:43
    关注

    1.pip uninstall pytest
    2.pip install pytest==5.3.0 表示指定安装Pytest版本为5.3.0版本
    3.重启pycharm 完美解决问题
    4.pip list 是显示当前所有的依赖包

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 9月11日
  • 已采纳回答 9月3日
  • 创建了问题 9月3日

悬赏问题

  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失
  • ¥15 springboot+vue 集成keycloak sso到阿里云
  • ¥15 win7系统进入桌面过一秒后突然黑屏
  • ¥30 backtrader对于期货交易的现金和资产计算的问题
  • ¥15 求C# .net4.8小报表工具
  • ¥15 安装虚拟机时出现问题
  • ¥15 Selenium+docker Chrome不能运行
  • ¥15 mac电脑,安装charles后无法正常抓包
  • ¥18 visio打开文件一直显示文件未找到