Add flake tests
Correct style in a few files to please Lord Travis
This commit is contained in:
parent
537028f88f
commit
87d65cac4a
53
.travis.yml
53
.travis.yml
@ -20,27 +20,38 @@ env:
|
||||
#- PYTHON=2.6 QT=pyqt TEST=standard
|
||||
- PYTHON=2.7 QT=pyqt TEST=extra
|
||||
- PYTHON=2.7 QT=pyside TEST=standard
|
||||
#- PYTHON=3.3 QT=pyqt TEST=standard
|
||||
#- PYTHON=3.3 QT=pyside TEST=standard
|
||||
- PYTHON=3.3 QT=pyqt TEST=standard
|
||||
- PYTHON=3.3 QT=pyside TEST=standard
|
||||
|
||||
|
||||
before_install:
|
||||
- travis_retry sudo apt-get -qq update;
|
||||
- if [ "${PYTHON}" != "2.7" ]; then
|
||||
wget http://repo.continuum.io/miniconda/Miniconda-2.2.2-Linux-x86_64.sh -O miniconda.sh &&
|
||||
chmod +x miniconda.sh &&
|
||||
./miniconda.sh -b &&
|
||||
export PATH=/home/$USER/anaconda/bin:$PATH &&
|
||||
conda update --yes conda &&
|
||||
travis_retry sudo apt-get -qq -y install libgl1-mesa-dri;
|
||||
fi;
|
||||
# - if [ "${PYTHON}" != "2.7" ]; then
|
||||
# wget http://repo.continuum.io/miniconda/Miniconda-2.2.2-Linux-x86_64.sh -O miniconda.sh &&
|
||||
# chmod +x miniconda.sh &&
|
||||
# ./miniconda.sh -b &&
|
||||
# export PATH=/home/$USER/anaconda/bin:$PATH &&
|
||||
# conda update --yes conda &&
|
||||
# travis_retry sudo apt-get -qq -y install libgl1-mesa-dri;
|
||||
# fi;
|
||||
|
||||
|
||||
install:
|
||||
- travis_retry sudo apt-get -qq -y install python-numpy;
|
||||
- pip install pytest
|
||||
|
||||
- if [ "${PYTHON}" != "2.7" ]; then
|
||||
- if [ "${PYTHON}" == "2.7" ]; then
|
||||
travis_retry sudo apt-get -qq -y install python-numpy python-pytest python-flake8;
|
||||
if [ ${QT} == 'pyqt' ]; then
|
||||
travis_retry sudo apt-get -qq -y install python-qt4 python-qt4-gl;
|
||||
else
|
||||
travis_retry sudo apt-get -qq -y install python-pyside.qtcore python-pyside.qtgui python-pyside.qtsvg python-pyside.qtopengl;
|
||||
fi;
|
||||
elif [ "${PYTHON}" == "3.3" ]; then
|
||||
travis_retry sudo apt-get -qq -y install python3-numpy python3-pytest python3-flake8;
|
||||
if [ ${QT} == 'pyqt' ]; then
|
||||
travis_retry sudo apt-get -qq -y install python3-qt4 python3-qt4-gl;
|
||||
else
|
||||
travis_retry sudo apt-get -qq -y install python3-pyside.qtcore python3-pyside.qtgui python3-pyside.qtsvg python3-pyside.qtopengl;
|
||||
fi;
|
||||
else
|
||||
conda create -n testenv --yes --quiet pip python=$PYTHON &&
|
||||
source activate testenv &&
|
||||
if [ ${QT} == 'pyqt' ]; then
|
||||
@ -48,12 +59,6 @@ install:
|
||||
else
|
||||
conda install --yes --quiet pyside;
|
||||
fi;
|
||||
else
|
||||
if [ ${QT} == 'pyqt' ]; then
|
||||
travis_retry sudo apt-get -qq -y install python-qt4 python-qt4-gl;
|
||||
else
|
||||
travis_retry sudo apt-get -qq -y install python-pyside.qtcore python-pyside.qtgui python-pyside.qtsvg python-pyside.qtopengl;
|
||||
fi;
|
||||
fi;
|
||||
|
||||
# Install PyOpenGL
|
||||
@ -75,7 +80,8 @@ before_script:
|
||||
|
||||
|
||||
script:
|
||||
- PYTHONPATH=. py.test
|
||||
# Run unit tests
|
||||
- python setup.py test
|
||||
|
||||
# check line endings
|
||||
- if [ "${TEST}" == "extra" ]; then
|
||||
@ -86,4 +92,9 @@ script:
|
||||
fi;
|
||||
fi;
|
||||
|
||||
# Check for style issues
|
||||
- if [ "${TEST}" == "extra" ]; then
|
||||
python setup.py style
|
||||
fi;
|
||||
|
||||
|
||||
|
@ -36,7 +36,7 @@ class PrintExporter(Exporter):
|
||||
dialog = QtGui.QPrintDialog(printer)
|
||||
dialog.setWindowTitle("Print Document")
|
||||
if dialog.exec_() != QtGui.QDialog.Accepted:
|
||||
return;
|
||||
return
|
||||
|
||||
#dpi = QtGui.QDesktopWidget().physicalDpiX()
|
||||
|
||||
|
@ -1666,7 +1666,8 @@ def isosurface(data, level):
|
||||
0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,
|
||||
0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99 , 0x190,
|
||||
0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,
|
||||
0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0 ], dtype=np.uint16)
|
||||
0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0
|
||||
], dtype=np.uint16)
|
||||
|
||||
## Table of triangles to use for filling each grid cell.
|
||||
## Each set of three integers tells us which three edges to
|
||||
|
@ -486,7 +486,7 @@ class PlotCurveItem(GraphicsObject):
|
||||
gl.glStencilOp(gl.GL_REPLACE, gl.GL_KEEP, gl.GL_KEEP)
|
||||
|
||||
## draw stencil pattern
|
||||
gl.glStencilMask(0xFF);
|
||||
gl.glStencilMask(0xFF)
|
||||
gl.glClear(gl.GL_STENCIL_BUFFER_BIT)
|
||||
gl.glBegin(gl.GL_TRIANGLES)
|
||||
gl.glVertex2f(rect.x(), rect.y())
|
||||
@ -520,7 +520,7 @@ class PlotCurveItem(GraphicsObject):
|
||||
gl.glEnable(gl.GL_LINE_SMOOTH)
|
||||
gl.glEnable(gl.GL_BLEND)
|
||||
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
|
||||
gl.glHint(gl.GL_LINE_SMOOTH_HINT, gl.GL_NICEST);
|
||||
gl.glHint(gl.GL_LINE_SMOOTH_HINT, gl.GL_NICEST)
|
||||
gl.glDrawArrays(gl.GL_LINE_STRIP, 0, pos.size / pos.shape[-1])
|
||||
finally:
|
||||
gl.glDisableClientState(gl.GL_VERTEX_ARRAY)
|
||||
|
@ -291,15 +291,16 @@ class PlotItem(GraphicsWidget):
|
||||
"""Return the :class:`ViewBox <pyqtgraph.ViewBox>` contained within."""
|
||||
return self.vb
|
||||
|
||||
## Wrap a few methods from viewBox.
|
||||
|
||||
## Wrap a few methods from viewBox.
|
||||
#Important: don't use a settattr(m, getattr(self.vb, m)) as we'd be leaving the viebox alive
|
||||
#because we had a reference to an instance method (creating wrapper methods at runtime instead).
|
||||
for m in [
|
||||
'setXRange', 'setYRange', 'setXLink', 'setYLink', 'setAutoPan', 'setAutoVisible',
|
||||
'setRange', 'autoRange', 'viewRect', 'viewRange', 'setMouseEnabled', 'setLimits',
|
||||
'enableAutoRange', 'disableAutoRange', 'setAspectLocked', 'invertY',
|
||||
'register', 'unregister']: ## NOTE: If you update this list, please update the class docstring as well.
|
||||
|
||||
for m in ['setXRange', 'setYRange', 'setXLink', 'setYLink', 'setAutoPan', # NOTE:
|
||||
'setAutoVisible', 'setRange', 'autoRange', 'viewRect', 'viewRange', # If you update this list, please
|
||||
'setMouseEnabled', 'setLimits', 'enableAutoRange', 'disableAutoRange', # update the class docstring
|
||||
'setAspectLocked', 'invertY', 'register', 'unregister']: # as well.
|
||||
|
||||
def _create_method(name):
|
||||
def method(self, *args, **kwargs):
|
||||
return getattr(self.vb, name)(*args, **kwargs)
|
||||
@ -310,6 +311,7 @@ class PlotItem(GraphicsWidget):
|
||||
|
||||
del _create_method
|
||||
|
||||
|
||||
def setLogMode(self, x=None, y=None):
|
||||
"""
|
||||
Set log scaling for x and/or y axes.
|
||||
|
@ -45,7 +45,7 @@ class GLAxisItem(GLGraphicsItem):
|
||||
|
||||
if self.antialias:
|
||||
glEnable(GL_LINE_SMOOTH)
|
||||
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
||||
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST)
|
||||
|
||||
glBegin( GL_LINES )
|
||||
|
||||
|
@ -59,7 +59,7 @@ class GLGridItem(GLGraphicsItem):
|
||||
glEnable(GL_LINE_SMOOTH)
|
||||
glEnable(GL_BLEND)
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
|
||||
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
||||
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST)
|
||||
|
||||
glBegin( GL_LINES )
|
||||
|
||||
|
@ -96,7 +96,7 @@ class GLLinePlotItem(GLGraphicsItem):
|
||||
glEnable(GL_LINE_SMOOTH)
|
||||
glEnable(GL_BLEND)
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
|
||||
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
||||
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST)
|
||||
|
||||
if self.mode == 'line_strip':
|
||||
glDrawArrays(GL_LINE_STRIP, 0, int(self.pos.size / self.pos.shape[-1]))
|
||||
|
@ -115,6 +115,6 @@ class WinTerm(object):
|
||||
# fill the entire screen with blanks
|
||||
win32.FillConsoleOutputCharacter(handle, ' ', dw_con_size, coord_screen)
|
||||
# now set the buffer's attributes accordingly
|
||||
win32.FillConsoleOutputAttribute(handle, self.get_attrs(), dw_con_size, coord_screen );
|
||||
win32.FillConsoleOutputAttribute(handle, self.get_attrs(), dw_con_size, coord_screen )
|
||||
# put the cursor at (0, 0)
|
||||
win32.SetConsoleCursorPosition(handle, (coord_screen.X, coord_screen.Y))
|
||||
|
6
setup.py
6
setup.py
@ -97,7 +97,11 @@ class Build(distutils.command.build.build):
|
||||
|
||||
setup(
|
||||
version=version,
|
||||
cmdclass={'build': Build, 'deb': helpers.DebCommand, 'test': helpers.TestCommand},
|
||||
cmdclass={'build': Build,
|
||||
'deb': helpers.DebCommand,
|
||||
'test': helpers.TestCommand,
|
||||
'debug': helpers.DebugCommand,
|
||||
'style': helpers.StyleCommand},
|
||||
packages=allPackages,
|
||||
package_dir={'pyqtgraph.examples': 'examples'}, ## install examples along with the rest of the source
|
||||
#package_data={'pyqtgraph': ['graphicsItems/PlotItem/*.png']},
|
||||
|
@ -9,9 +9,37 @@ except ImportError:
|
||||
output = proc.stdout.read()
|
||||
proc.wait()
|
||||
if proc.returncode != 0:
|
||||
raise Exception("Process had nonzero return value", proc.returncode)
|
||||
ex = Exception("Process had nonzero return value %d" % proc.returncode)
|
||||
ex.returncode = proc.returncode
|
||||
ex.output = output
|
||||
raise ex
|
||||
return output
|
||||
|
||||
FLAKE_TESTS = ("E101,E111,E112,E113,E122,E125,E133,E223,E224,"
|
||||
"E242,E273,E274,E304,E502,E703,E901,E902,"
|
||||
"W191,W601,W602,W603,W604")
|
||||
|
||||
def checkStyle():
|
||||
try:
|
||||
out = check_output(['flake8', '--select=%s' % FLAKE_TESTS, '--statistics', 'pyqtgraph/'])
|
||||
ret = 0
|
||||
print("All style checks OK.")
|
||||
except Exception as e:
|
||||
out = e.output
|
||||
ret = e.returncode
|
||||
print(out)
|
||||
return ret
|
||||
|
||||
def unitTests():
|
||||
try:
|
||||
out = check_output('PYTHONPATH=. py.test', shell=True)
|
||||
ret = 0
|
||||
except Exception as e:
|
||||
out = e.output
|
||||
ret = e.returncode
|
||||
print(out)
|
||||
return ret
|
||||
|
||||
def listAllPackages(pkgroot):
|
||||
path = os.getcwd()
|
||||
n = len(path.split(os.path.sep))
|
||||
@ -190,8 +218,8 @@ class DebCommand(Command):
|
||||
raise Exception("Error during debuild.")
|
||||
|
||||
|
||||
class TestCommand(Command):
|
||||
"""Just for learning about distutils; not for running package tests."""
|
||||
class DebugCommand(Command):
|
||||
"""Just for learning about distutils."""
|
||||
description = ""
|
||||
user_options = []
|
||||
def initialize_options(self):
|
||||
@ -203,3 +231,33 @@ class TestCommand(Command):
|
||||
cmd = self
|
||||
print(self.distribution.name)
|
||||
print(self.distribution.version)
|
||||
|
||||
|
||||
class TestCommand(Command):
|
||||
description = "Run all package tests and exit immediately with informative return code."
|
||||
user_options = []
|
||||
|
||||
def run(self):
|
||||
sys.exit(unitTests())
|
||||
|
||||
|
||||
def initialize_options(self):
|
||||
pass
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
|
||||
class StyleCommand(Command):
|
||||
description = "Check all code for style, exit immediately with informative return code."
|
||||
user_options = []
|
||||
|
||||
def run(self):
|
||||
sys.exit(checkStyle())
|
||||
|
||||
def initialize_options(self):
|
||||
pass
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user