gpt4 book ai didi

python - 运行时错误 : could not open display

转载 作者:行者123 更新时间:2023-11-28 17:27:48 26 4
gpt4 key购买 nike

我有一个包含

的单元测试
import gtk

其中包含用于测试信号处理程序和 GUI 类的单元测试。当我从 shell 运行 py.test 时效果很好,因为我连接了 X11 显示器。但是,当我尝试运行 tox 时,我得到:

______________________ ERROR collecting tests/test_gui.py ______________________
tests/test_gui.py:17: in <module>
from rprs_bootstrap.gui import GUI
src/gui.py:12: in <module>
import gtk.glade
.tox/py27/lib/python2.7/site-packages/gtk-2.0/gtk/__init__.py:64: in <module>
_init()
.tox/py27/lib/python2.7/site-packages/gtk-2.0/gtk/__init__.py:52: in _init
_gtk.init_check()
E RuntimeError: could not open display
!!!!!!!!!!!!!!!!!!!! Interrupted: stopping after 1 failures !!!!!!!!!!!!!!!!!!!!
=========================== 1 error in 0.34 seconds ============================
make: *** [tox] Error 2

我可以开始 Xvfb tox.ini 中的服务器,但这似乎不够优雅。 有什么建议吗?

最佳答案

使用pytest-xvfb

哪个

[...] runs your testsuite with Xvfb to avoid popping up windows during GUI tests or allow them to run on systems without a display (like a CI).

安装:

pip install pytest-xvfb

关于python - 运行时错误 : could not open display,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37301623/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com