【发布时间】:2016-08-16 06:41:19
【问题描述】:
我一直在 Travis 下测试一个 Python 应用程序,效果非常好。但是,我现在正在尝试测试以下语句:
webbrowser.open_new_tab(outputFile)
当这行代码执行时,Travis 会记录:
≪ ↑ ↓ 查看
在过去 10 秒内未收到任何输出,这可能表示构建停滞或构建本身有问题。
构建已终止
如何阻止 Travis 被生成外部应用程序(浏览器 - 可能是 Firefox)的代码阻止?我按如下方式运行测试:
xvfb-run --server-args="-screen 0, 1024x768x24" nosetests -s --nologcapture -A 'not slow' -v --with-id --with-xcoverage --with-xunit --verbose --cover-package=qgis2web
我还尝试了以下调用xvfb(来自https://docs.travis-ci.com/user/gui-and-headless-browsers/)的替代方式:
- before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start
或:
-before_install:
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16"
然后直接调用测试:
nosetests -s --nologcapture -A 'not slow' -v --with-id --with-xcoverage --with-xunit --verbose --cover-package=qgis2web
两者都会导致“无法连接到 X”类型错误。
如何阻止webbrowser 阻止?
编辑: 测试也是用 Python 编写的。
【问题讨论】:
-
command &适用于 86% 的案例 -
@набиячлэвэлиь 抱歉,你能扩展一下吗?我不明白你的意思。
-
要以非阻塞方式运行
command,您可以执行command & -
我提到的
webbrowser命令是用Python 编写的测试套件的一部分。command &给出语法错误。