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

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

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

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

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

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

qxsslcnc

qxsslcnc1#

你可以试着

  1. from pytest import console_main

字符串

  1. from pytest import *

相关问题