Skip to content

Commit 3d48a66

Browse files
committed
Added unattended tests with multiple versions of WinPython
Tested with: WinPython-32bit-2.7.6.4 WinPython-64bit-2.7.6.4 WinPython-64bit-3.4.4.3 WinPython-64bit-3.4.4.3Qt5 WPy64-3680 WPy64-3771 WPy64-3830
1 parent 1b6b436 commit 3d48a66

18 files changed

+239
-307
lines changed

basic_test.bat

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@echo off
2+
3+
setlocal
4+
set PYTHONPATH=%cd%
5+
set TEST_UNATTENDED=1
6+
7+
for /f %%f in ('dir /b c:\w*') do (call :test %%f)
8+
pause
9+
10+
exit /B %ERRORLEVEL%
11+
12+
:test
13+
set ENV=C:\%~1\scripts\env.bat
14+
if exist %ENV% (
15+
echo ************************** Testing with %~1 **************************
16+
call %ENV%
17+
python -m qwt.tests.__init__
18+
)
19+
exit /B 0

qwt/tests/BodeDemo.py

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@
1010

1111
SHOW = True # Show test in GUI-based test launcher
1212

13-
import sys
1413
import numpy as np
1514

16-
from qwt.qt.QtGui import (QApplication, QPen, QBrush, QFrame, QFont, QWidget,
17-
QMainWindow, QToolButton, QIcon, QPixmap, QToolBar,
18-
QHBoxLayout, QLabel, QPrinter, QPrintDialog,
19-
QFontDatabase)
20-
from qwt.qt.QtCore import QSize
21-
from qwt.qt.QtCore import Qt
15+
from qwt.qt.QtGui import (QPen, QBrush, QFrame, QFont, QWidget, QMainWindow,
16+
QToolButton, QIcon, QPixmap, QToolBar, QHBoxLayout,
17+
QLabel, QPrinter, QPrintDialog)
18+
from qwt.qt.QtCore import QSize, Qt
2219
from qwt import (QwtPlot, QwtPlotMarker, QwtSymbol, QwtLegend, QwtPlotGrid,
2320
QwtPlotCurve, QwtPlotItem, QwtLogScaleEngine, QwtText,
2421
QwtPlotRenderer)
@@ -281,19 +278,6 @@ def selected(self, _):
281278
self.showInfo()
282279

283280

284-
def make():
285-
demo = BodeDemo()
286-
demo.resize(540, 400)
287-
demo.show()
288-
return demo
289-
290-
291281
if __name__ == '__main__':
292-
app = QApplication(sys.argv)
293-
fonts = QFontDatabase()
294-
for name in ('Verdana', 'STIXGeneral'):
295-
if name in fonts.families():
296-
app.setFont(QFont(name))
297-
break
298-
demo = make()
299-
sys.exit(app.exec_())
282+
from qwt.tests import test_widget
283+
app = test_widget(BodeDemo, (540, 400))

qwt/tests/CPUplot.py

Lines changed: 33 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@
99
SHOW = True # Show test in GUI-based test launcher
1010

1111
import os
12-
import sys
1312
import numpy as np
1413

15-
from qwt.qt.QtGui import (QApplication, QColor, QBrush, QWidget, QVBoxLayout,
16-
QLabel)
17-
from qwt.qt.QtCore import QRect, QTime
18-
from qwt.qt.QtCore import Qt
14+
from qwt.qt.QtGui import QColor, QBrush, QWidget, QVBoxLayout, QLabel
15+
from qwt.qt.QtCore import QRect, QTime, Qt
1916
from qwt import (QwtPlot, QwtPlotMarker, QwtScaleDraw, QwtLegend, QwtPlotCurve,
2017
QwtPlotItem, QwtLegendData, QwtText)
2118

@@ -176,20 +173,20 @@ def __init__(self):
176173

177174
def statistic(self):
178175
values = self.__lookup()
179-
userDelta = 0.0
176+
userDelta = 0.
180177
for i in [CpuStat.User, CpuStat.Nice]:
181178
userDelta += (values[i] - self.procValues[i])
182179
systemDelta = values[CpuStat.System] - self.procValues[CpuStat.System]
183-
totalDelta = 0.0
180+
totalDelta = 0.
184181
for i in range(len(self.procValues)):
185182
totalDelta += (values[i] - self.procValues[i])
186183
self.procValues = values
187-
return 100.0*userDelta/totalDelta, 100.0*systemDelta/totalDelta
184+
return 100.*userDelta/totalDelta, 100.*systemDelta/totalDelta
188185

189186
def upTime(self):
190187
result = QTime()
191188
for item in self.procValues:
192-
result = result.addSecs(item/100)
189+
result = result.addSecs(int(.01*item))
193190
return result
194191

195192
def __lookup(self):
@@ -208,7 +205,7 @@ def __lookup(self):
208205
class CpuPieMarker(QwtPlotMarker):
209206
def __init__(self, *args):
210207
QwtPlotMarker.__init__(self, *args)
211-
self.setZ(1000.0)
208+
self.setZ(1000.)
212209
self.setRenderHint(QwtPlotItem.RenderAntialiased, True)
213210

214211
def rtti(self):
@@ -219,18 +216,18 @@ def draw(self, painter, xMap, yMap, rect):
219216
pieRect = QRect()
220217
pieRect.setX(rect.x() + margin)
221218
pieRect.setY(rect.y() + margin)
222-
pieRect.setHeight(yMap.transform(80.0))
219+
pieRect.setHeight(int(yMap.transform(80.)))
223220
pieRect.setWidth(pieRect.height())
224221

225222
angle = 3*5760/4
226223
for key in ["User", "System", "Idle"]:
227224
curve = self.plot().cpuPlotCurve(key)
228225
if curve.dataSize():
229-
value = int(5760*curve.sample(0).y()/100.0)
226+
value = int(5760*curve.sample(0).y()/100.)
230227
painter.save()
231228
painter.setBrush(QBrush(curve.pen().color(),
232229
Qt.SolidPattern))
233-
painter.drawPie(pieRect, -angle, -value)
230+
painter.drawPie(pieRect, int(-angle), int(-value))
234231
painter.restore()
235232
angle += value
236233

@@ -248,7 +245,7 @@ def label(self, value):
248245
class Background(QwtPlotItem):
249246
def __init__(self):
250247
QwtPlotItem.__init__(self)
251-
self.setZ(0.0)
248+
self.setZ(0.)
252249

253250
def rtti(self):
254251
return QwtPlotItem.Rtti_PlotUserItem
@@ -258,8 +255,8 @@ def draw(self, painter, xMap, yMap, rect):
258255
r = QRect(rect)
259256

260257
for i in range(100, 0, -10):
261-
r.setBottom(yMap.transform(i - 10))
262-
r.setTop(yMap.transform(i))
258+
r.setBottom(int(yMap.transform(i - 10)))
259+
r.setTop(int(yMap.transform(i)))
263260
painter.fillRect(r, c)
264261
c = c.darker(110)
265262

@@ -285,7 +282,7 @@ def __init__(self, *args):
285282

286283
self.curves = {}
287284
self.data = {}
288-
self.timeData = 1.0 * np.arange(HISTORY-1, -1, -1)
285+
self.timeData = 1. * np.arange(HISTORY-1, -1, -1)
289286
self.cpuStat = CpuStat()
290287

291288
self.setAutoReplot(False)
@@ -300,7 +297,7 @@ def __init__(self, *args):
300297
self.setAxisScaleDraw(
301298
QwtPlot.xBottom, TimeScaleDraw(self.cpuStat.upTime()))
302299
self.setAxisScale(QwtPlot.xBottom, 0, HISTORY)
303-
self.setAxisLabelRotation(QwtPlot.xBottom, -50.0)
300+
self.setAxisLabelRotation(QwtPlot.xBottom, -50.)
304301
self.setAxisLabelAlignment(
305302
QwtPlot.xBottom, Qt.AlignLeft | Qt.AlignBottom)
306303

@@ -321,21 +318,21 @@ def __init__(self, *args):
321318

322319
curve = CpuCurve('User')
323320
curve.setColor(Qt.blue)
324-
curve.setZ(curve.z() - 1.0)
321+
curve.setZ(curve.z() - 1.)
325322
curve.attach(self)
326323
self.curves['User'] = curve
327324
self.data['User'] = np.zeros(HISTORY, np.float)
328325

329326
curve = CpuCurve('Total')
330327
curve.setColor(Qt.black)
331-
curve.setZ(curve.z() - 2.0)
328+
curve.setZ(curve.z() - 2.)
332329
curve.attach(self)
333330
self.curves['Total'] = curve
334331
self.data['Total'] = np.zeros(HISTORY, np.float)
335332

336333
curve = CpuCurve('Idle')
337334
curve.setColor(Qt.darkCyan)
338-
curve.setZ(curve.z() - 3.0)
335+
curve.setZ(curve.z() - 3.)
339336
curve.attach(self)
340337
self.curves['Idle'] = curve
341338
self.data['Idle'] = np.zeros(HISTORY, np.float)
@@ -355,9 +352,9 @@ def timerEvent(self, e):
355352
data[1:] = data[0:-1]
356353
self.data["User"][0], self.data["System"][0] = self.cpuStat.statistic()
357354
self.data["Total"][0] = self.data["User"][0] + self.data["System"][0]
358-
self.data["Idle"][0] = 100.0 - self.data["Total"][0]
355+
self.data["Idle"][0] = 100. - self.data["Total"][0]
359356

360-
self.timeData += 1.0
357+
self.timeData += 1.
361358

362359
self.setAxisScale(
363360
QwtPlot.xBottom, self.timeData[-1], self.timeData[0])
@@ -375,25 +372,18 @@ def cpuPlotCurve(self, key):
375372
return self.curves[key]
376373

377374

378-
def make():
379-
demo = QWidget()
380-
demo.setWindowTitle('Cpu Plot')
381-
382-
plot = CpuPlot(demo)
383-
plot.setTitle("History")
384-
385-
label = QLabel("Press the legend to en/disable a curve", demo)
386-
387-
layout = QVBoxLayout(demo)
388-
layout.addWidget(plot)
389-
layout.addWidget(label)
390-
391-
demo.resize(600, 400)
392-
demo.show()
393-
return demo
394-
375+
class CpuWidget(QWidget):
376+
def __init__(self, parent=None):
377+
super(CpuWidget, self).__init__(parent)
378+
layout = QVBoxLayout()
379+
self.setLayout(layout)
380+
plot = CpuPlot()
381+
plot.setTitle("History")
382+
layout.addWidget(plot)
383+
label = QLabel("Press the legend to en/disable a curve")
384+
layout.addWidget(label)
385+
395386

396387
if __name__ == '__main__':
397-
app = QApplication(sys.argv)
398-
demo = make()
399-
sys.exit(app.exec_())
388+
from qwt.tests import test_widget
389+
app = test_widget(CpuWidget, (600, 400))

qwt/tests/CartesianDemo.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88

99
SHOW = True # Show test in GUI-based test launcher
1010

11-
import sys
1211
import numpy as np
1312

14-
from qwt.qt.QtGui import QApplication, QPen
13+
from qwt.qt.QtGui import QPen
1514
from qwt.qt.QtCore import Qt
1615
from qwt import QwtPlot, QwtScaleDraw, QwtPlotGrid, QwtPlotCurve, QwtPlotItem
1716

@@ -89,14 +88,6 @@ def __init__(self, *args):
8988
self.replot()
9089

9190

92-
def make():
93-
demo = CartesianPlot()
94-
demo.resize(400, 300)
95-
demo.show()
96-
return demo
97-
98-
9991
if __name__ == '__main__':
100-
app = QApplication(sys.argv)
101-
demo = make()
102-
sys.exit(app.exec_())
92+
from qwt.tests import test_widget
93+
test_widget(CartesianPlot, (400, 300))

qwt/tests/CurveBenchmark.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010

1111
import time
1212
import numpy as np
13-
import sys
1413

1514
from qwt.qt.QtGui import (QApplication, QPen, QMainWindow, QGridLayout,
16-
QTabWidget, QWidget, QTextEdit, QLineEdit, QFont,
17-
QFontDatabase)
15+
QTabWidget, QWidget, QTextEdit, QLineEdit)
1816
from qwt.qt.QtCore import Qt
1917

2018
import os
@@ -78,7 +76,7 @@ def params(self, *args, **kwargs):
7876
)
7977

8078
def setup(self, points, *args, **kwargs):
81-
x = np.linspace(.001, 20., points)
79+
x = np.linspace(.001, 20., int(points))
8280
y = (np.sin(x)/x)*np.cos(20*x)
8381
layout = QGridLayout()
8482
nbcol, col, row = 2, 0, 0
@@ -121,11 +119,11 @@ def __init__(self, parent=None, title=None):
121119
""" % (title, library))
122120

123121

124-
class BMDemo(QMainWindow):
122+
class BMDemo1(QMainWindow):
125123
TITLE = 'Curve benchmark'
126124
SIZE = (1000, 800)
127-
def __init__(self, max_n, parent=None, **kwargs):
128-
super(BMDemo, self).__init__(parent=parent)
125+
def __init__(self, max_n=1000000, parent=None, **kwargs):
126+
super(BMDemo1, self).__init__(parent=parent)
129127
title = self.TITLE
130128
if kwargs.get('only_lines', False):
131129
title = '%s (%s)' % (title, 'only lines')
@@ -169,13 +167,5 @@ def run_benchmark(self, max_n, **kwargs):
169167

170168

171169
if __name__ == '__main__':
172-
app = QApplication([])
173-
for name in ('Calibri', 'Verdana', 'Arial'):
174-
if name in QFontDatabase().families():
175-
app.setFont(QFont(name))
176-
break
177-
kwargs = {}
178-
for arg in sys.argv[1:]:
179-
kwargs[arg] = True
180-
demo = BMDemo(1000000, **kwargs)
181-
app.exec_()
170+
from qwt.tests import test_widget
171+
app = test_widget(BMDemo1)

qwt/tests/CurveDemo1.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@
88

99
SHOW = True # Show test in GUI-based test launcher
1010

11-
import sys
1211
import numpy as np
1312

14-
from qwt.qt.QtGui import (QApplication, QPen, QBrush, QFrame, QFont, QPainter,
15-
QPaintEngine)
13+
from qwt.qt.QtGui import QPen, QBrush, QFrame, QFont, QPainter, QPaintEngine
1614
from qwt.qt.QtCore import QSize
1715
from qwt.qt.QtCore import Qt
1816
from qwt import QwtSymbol, QwtPlotCurve, QwtPlotItem, QwtScaleMap
1917

2018

21-
class CurveDemo(QFrame):
19+
class CurveDemo1(QFrame):
2220
def __init__(self, *args):
2321
QFrame.__init__(self, *args)
2422

@@ -118,14 +116,6 @@ def drawContents(self, painter):
118116
self.shiftDown(r, dy)
119117

120118

121-
def make():
122-
demo = CurveDemo()
123-
demo.resize(300, 600)
124-
demo.show()
125-
return demo
126-
127-
128119
if __name__ == '__main__':
129-
app = QApplication(sys.argv)
130-
demo = make()
131-
sys.exit(app.exec_())
120+
from qwt.tests import test_widget
121+
app = test_widget(CurveDemo1, size=(300, 600))

0 commit comments

Comments
 (0)