python-3.x pytest- getting无法导入名称'console_main'

pxy2qtax  于 2023-11-20  发布在  Python
关注(0)|答案(1)|浏览(209)

我尝试使用pytest运行Python测试,但我得到错误“ImportError:cannot import name 'console_main' from 'pytest'(unknown location)”
我使用pytest运行测试,但得到下面的错误。

Traceback (most recent call last):
  File "/tmp/func/bin/pytest", line 5, in <module>
    from pytest import console_main
ImportError: cannot import name 'console_main' from 'pytest' (unknown location)

字符串
这是“/tmp/func/bin/pytest”中的代码

#!/tmp/func/bin/python3.8
# -*- coding: utf-8 -*-
import re
import sys
from pytest import console_main
if __name__ == '__main__':
  sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
  sys.exit(console_main())

qxsslcnc

qxsslcnc1#

你可以试着

from pytest import console_main

字符串

from pytest import *

相关问题