pytest中所有测试用例的超时

时间:2017-03-16 08:56:50

标签: pytest

我要求在整体超时时停止测试用例,而不是在测试用例级别。 所以如果我说我有300个测试用例,我希望超时,总时间为300秒。

有办法吗? 用于运行pytest的示例命令 pytest.py --junitxml = artifacts / junitresults.xml -s --gatherlogs = true --durations = 2000 tests / spark

1 个答案:

答案 0 :(得分:5)

看看这个pytest插件:https://pypi.python.org/pypi/pytest-timeout它最有可能适合你的用例。

您可以通过多种方式设置全局超时,最简单的方法是var Newt = React.createClass({ getInitialState: function () { return { greeting: 'This is really', thing: 'code stuff' }; }, render: function () { return ( <div id="react-newt"> {this.state.greeting} {this.state.thing}! </div> ); } }); $(function () { if (document.getElementById('newt')) { React.render( <Newt />, document.getElementById('newt') ); console.log('newt'); } }); 命令行选项“设置覆盖环境变量和配置选项的全局超时”,之后测试将是终止:

# Generate some example data.
set table "heatmap.dat"
set isosamples 1000,100
splot x
unset table

set table "ellipse.dat"
set parametric
plot 8*sin(t),5*cos(t)
unset parametric
unset table

# Set this explicitly to let the borders of the two plots match exactly.
set lmargin at screen 0.1
set rmargin at screen 0.85
set bmargin at screen 0.1
set tmargin at screen 0.9
set xrange [-10:10]
set yrange [-10:10]

# We are going to produce a png file
set terminal pngcairo

# First plot of the heatmap, this will be the background.
set output "a.png"
plot "heatmap.dat" with image


# Plot again, we need the dummy heatmap for the color key.
# We use the rectangle object for filling the area outside the ellipse. (Thanks @ewcz)
# Later we interprete the color 444444 as transparent.
set output "b.png"
set object rectangle from -10,-10 to 10,10 fc rgb "#f0ddaa" fillstyle solid 1.0
plot "heatmap.dat" using 1:2:(NaN) with image notitle,\
     "ellipse.dat" using 1:2 with filledcurves lc rgb "#444444" notitle


# Overlay the pictures using imagemagick. The result is "result.png".
system('convert b.png -transparent "#444444" c.png')
system('composite -compose atop c.png a.png result.png')
相关问题