Merge pull request #1131 from j9ac9k/update-ci-fix-tests

Update CI/tox and Enable More Tests
This commit is contained in:
Ogi Moore 2020-03-06 10:47:05 -08:00 committed by GitHub
commit 19670a8469
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 98 additions and 318 deletions

View File

@ -1,12 +0,0 @@
Luke Campagnola <lcampagn@email.unc.edu> Luke Campagnola <>
Luke Campagnola <lcampagn@email.unc.edu> Luke Campagnola <luke.campagnola@gmail.com>
Megan Kratz <meganbkratz@gmail.com> meganbkratz@gmail.com <>
Megan Kratz <meganbkratz@gmail.com> Megan Kratz <megankratz@megancomputer.local>
Megan Kratz <meganbkratz@gmail.com> Megan Kratz <megankratz@wireless152023024102.med.unc.edu>
Megan Kratz <meganbkratz@gmail.com> Megan Kratz <megankratz@wireless152023025209.med.unc.edu>
Megan Kratz <meganbkratz@gmail.com> Megan Kratz <megankratz@p152023031037.med.unc.edu>
Megan Kratz <meganbkratz@gmail.com> Megan Kratz <megankratz@wire152019114033.med.unc.edu>
Megan Kratz <meganbkratz@gmail.com> Megan Kratz <megankratz@wireless152023024078.med.unc.edu>
Ingo Breßler <dev@ingobressler.net> Ingo Breßler <ingo.bressler@bam.de>
Ingo Breßler <dev@ingobressler.net> Ingo B. <dev@ingobressler.net>

View File

@ -1,195 +0,0 @@
language: python
sudo: false
# Credit: Original .travis.yml lifted from VisPy
# Here we use anaconda for 2.6 and 3.3, since it provides the simplest
# interface for running different versions of Python. We could also use
# it for 2.7, but the Ubuntu system has installable 2.7 Qt4-GL, which
# allows for more complete testing.
notifications:
email: false
env:
# Enable python 2 and python 3 builds
# Note that the python 2.6 support ended.
- PYTHON=2.7 QT=pyqt4 TEST=extra
- PYTHON=2.7 QT=pyside TEST=standard
- PYTHON=3.5 QT=pyqt5 TEST=standard
# - PYTHON=3.4 QT=pyside TEST=standard # pyside isn't available for 3.4 with conda
#- PYTHON=3.2 QT=pyqt5 TEST=standard
services:
- xvfb
before_install:
- if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then wget http://repo.continuum.io/miniconda/Miniconda-3.5.5-Linux-x86_64.sh -O miniconda.sh; else wget http://repo.continuum.io/miniconda/Miniconda3-3.5.5-Linux-x86_64.sh -O miniconda.sh; fi
- chmod +x miniconda.sh
- ./miniconda.sh -b -p /home/travis/mc
- export PATH=/home/travis/mc/bin:$PATH
# not sure what is if block is for
- if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then
GIT_TARGET_EXTRA="+refs/heads/${TRAVIS_BRANCH}";
GIT_SOURCE_EXTRA="+refs/pull/${TRAVIS_PULL_REQUEST}/merge";
else
GIT_TARGET_EXTRA="";
GIT_SOURCE_EXTRA="";
fi;
# to aid in debugging
- echo ${TRAVIS_BRANCH}
- echo ${TRAVIS_REPO_SLUG}
- echo ${GIT_TARGET_EXTRA}
- echo ${GIT_SOURCE_EXTRA}
install:
- export GIT_FULL_HASH=`git rev-parse HEAD`
- conda update conda --yes
- conda create -n test_env python=${PYTHON} --yes
- source activate test_env
- conda install numpy scipy pyopengl pytest flake8 six coverage --yes
- echo ${QT}
- echo ${TEST}
- echo ${PYTHON}
- if [ "${QT}" == "pyqt5" ]; then
conda install pyqt --yes;
fi;
- if [ "${QT}" == "pyqt4" ]; then
conda install pyqt=4 --yes;
fi;
- if [ "${QT}" == "pyside" ]; then
conda install pyside --yes;
fi;
- pip install pytest-xdist # multi-thread pytest
- pip install pytest-cov # add coverage stats
# faulthandler support not built in to pytest for python 2.7
- if [ "${PYTHON}" == "2.7" ]; then
pip install pytest-faulthandler;
export PYTEST_ADDOPTS="--faulthandler-timeout=15";
fi;
# Debugging helpers
- uname -a
- cat /etc/issue
- if [ "${PYTHON}" == "2.7" ]; then
python --version;
else
python3 --version;
fi;
before_script:
# We need to create a (fake) display on Travis, let's use a funny resolution
- export DISPLAY=:99.0
- /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1400x900x24 -ac +extension GLX +render
# Make sure everyone uses the correct python (this is handled by conda)
- which python
- python --version
- pwd
- ls
# Help color output from each test
- RESET='\033[0m';
RED='\033[00;31m';
GREEN='\033[00;32m';
YELLOW='\033[00;33m';
BLUE='\033[00;34m';
PURPLE='\033[00;35m';
CYAN='\033[00;36m';
WHITE='\033[00;37m';
start_test() {
echo -e "${BLUE}======== Starting $1 ========${RESET}";
};
check_output() {
ret=$?;
if [ $ret == 0 ]; then
echo -e "${GREEN}>>>>>> $1 passed <<<<<<${RESET}";
else
echo -e "${RED}>>>>>> $1 FAILED <<<<<<${RESET}";
fi;
return $ret;
};
- if [ "${TEST}" == "extra" ]; then
start_test "repo size check";
mkdir ~/repo-clone && cd ~/repo-clone &&
git init && git remote add -t ${TRAVIS_BRANCH} origin git://github.com/${TRAVIS_REPO_SLUG}.git &&
git fetch origin ${GIT_TARGET_EXTRA} &&
git checkout -qf FETCH_HEAD &&
git tag travis-merge-target &&
git gc --aggressive &&
TARGET_SIZE=`du -s . | sed -e "s/\t.*//"` &&
git pull origin ${GIT_SOURCE_EXTRA} &&
git gc --aggressive &&
MERGE_SIZE=`du -s . | sed -e "s/\t.*//"` &&
if [ "${MERGE_SIZE}" != "${TARGET_SIZE}" ]; then
SIZE_DIFF=`expr \( ${MERGE_SIZE} - ${TARGET_SIZE} \)`;
else
SIZE_DIFF=0;
fi;
fi;
script:
- source activate test_env
# Check system info
- python -c "import pyqtgraph as pg; pg.systemInfo()"
# Check install works
- start_test "install test";
python setup.py --quiet install;
check_output "install test";
# Run unit tests
- start_test "unit tests";
PYTHONPATH=. pytest --cov pyqtgraph -sv;
check_output "unit tests";
- echo "test script finished. Current directory:"
- pwd
# check line endings
- if [ "${TEST}" == "extra" ]; then
start_test "line ending check";
! find ./ -name "*.py" | xargs file | grep CRLF &&
! find ./ -name "*.rst" | xargs file | grep CRLF;
check_output "line ending check";
fi;
# Check repo size does not expand too much
- if [ "${TEST}" == "extra" ]; then
start_test "repo size check";
echo -e "Estimated content size difference = ${SIZE_DIFF} kB" &&
test ${SIZE_DIFF} -lt 100;
check_output "repo size check";
fi;
# Check for style issues
- if [ "${TEST}" == "extra" ]; then
start_test "style check";
cd ~/repo-clone &&
git reset -q travis-merge-target &&
python setup.py style &&
check_output "style check";
fi;
# Check double-install fails
# Note the bash -c is because travis strips off the ! otherwise.
- start_test "double install test";
bash -c "! python setup.py --quiet install";
check_output "double install test";
# Check we can import pg
- start_test "import test";
echo "import sys; print(sys.path)" | python &&
cd /; echo "import pyqtgraph.examples" | python;
check_output "import test";
after_success:
- cd /home/travis/build/pyqtgraph/pyqtgraph
- pip install codecov --upgrade # add coverage integration service
- codecov
- pip install coveralls --upgrade # add another coverage integration service
- coveralls

View File

@ -9,11 +9,14 @@ Please use the following guidelines when preparing changes:
* The preferred method for submitting changes is by github pull request against the "develop" branch. * The preferred method for submitting changes is by github pull request against the "develop" branch.
* Pull requests should include only a focused and related set of changes. Mixed features and unrelated changes may be rejected. * Pull requests should include only a focused and related set of changes. Mixed features and unrelated changes may be rejected.
* For major changes, it is recommended to discuss your plans on the mailing list or in a github issue before putting in too much effort. * For major changes, it is recommended to discuss your plans on the mailing list or in a github issue before putting in too much effort.
* Along these lines, please note that `pyqtgraph.opengl` will be deprecated soon and replaced with VisPy. * The following deprecations are being considered by the maintainers
* `pyqtgraph.opengl` may be deprecated and replaced with `VisPy` functionality
* After v0.11, pyqtgraph will adopt [NEP-29](https://numpy.org/neps/nep-0029-deprecation_policy.html) which will effectively mean that python2 support will be deprecated
* Qt4 will be deprecated shortly, as well as Qt5<5.9 (and potentially <5.12)
## Documentation ## Documentation
* Writing proper documentation and unit tests is highly encouraged. PyQtGraph uses nose / pytest style testing, so tests should usually be included in a tests/ directory adjacent to the relevant code. * Writing proper documentation and unit tests is highly encouraged. PyQtGraph uses pytest style testing, so tests should usually be included in a tests/ directory adjacent to the relevant code.
* Documentation is generated with sphinx; please check that docstring changes compile correctly * Documentation is generated with sphinx; please check that docstring changes compile correctly
## Style guidelines ## Style guidelines
@ -55,9 +58,7 @@ To make use of `pre-commit`, have it available in your `$PATH` and run `pre-comm
* pytest-xdist * pytest-xdist
* Optional: pytest-xvfb * Optional: pytest-xvfb
If you have pytest < 5, you may also want to install the pytest-faulthandler If you have `pytest<5` (used in python2), you may also want to install `pytest-faulthandler==1.6` plugin to output extra debugging information in case of test failures. This isn't necessary with `pytest>=5`
plugin to output extra debugging information in case of test failures. This
isn't necessary with pytest 5+ as the plugin was merged into core pytest.
### Tox ### Tox
@ -68,13 +69,4 @@ As PyQtGraph supports a wide array of Qt-bindings, and python versions, we make
### Continous Integration ### Continous Integration
For our Continuous Integration, we utilize Azure Pipelines. On each OS, we test the following 6 configurations For our Continuous Integration, we utilize Azure Pipelines. Tested configurations are visible on [README](README.md). More information on coverage and test failures can be found on the respective tabs of the [build results page](https://dev.azure.com/pyqtgraph/pyqtgraph/_build?definitionId=1)
* Python2.7 with PyQt4
* Python2.7 with PySide
* Python3.6 with PyQt5-5.9
* Python3.6 with PySide2-5.9
* Python3.7 with PyQt5-5.12
* Python3.7 with PySide2-5.12
More information on coverage and test failures can be found on the respective tabs of the [build results page](https://dev.azure.com/pyqtgraph/pyqtgraph/_build?definitionId=1)

View File

@ -1,7 +1,6 @@
[![Build Status](https://pyqtgraph.visualstudio.com/pyqtgraph/_apis/build/status/pyqtgraph.pyqtgraph?branchName=develop)](https://pyqtgraph.visualstudio.com/pyqtgraph/_build/latest?definitionId=17&branchName=develop) [![Build Status](https://pyqtgraph.visualstudio.com/pyqtgraph/_apis/build/status/pyqtgraph.pyqtgraph?branchName=develop)](https://pyqtgraph.visualstudio.com/pyqtgraph/_build/latest?definitionId=17&branchName=develop)
PyQtGraph PyQtGraph
========= =========
@ -20,7 +19,8 @@ Requirements
------------ ------------
* PyQt 4.8+, PySide, PyQt5, or PySide2 * PyQt 4.8+, PySide, PyQt5, or PySide2
* python 2.7, or 3.x * PySide2 5.14 does not have loadUiType functionality, and thus the example application will not work. You can follow along with restoring that functionality [here](https://bugreports.qt.io/browse/PYSIDE-1223).
* Python 2.7, or 3.x
* Required * Required
* `numpy` * `numpy`
* Optional * Optional
@ -34,14 +34,15 @@ Requirements
Qt Bindings Test Matrix Qt Bindings Test Matrix
----------------------- -----------------------
Below is a table of the configurations we test and have confidence pyqtgraph will work with. All current operating major operating systems (Windows, macOS, Linux) are tested against this configuration. We recommend using the Qt 5.12 or 5.9 (either PyQt5 or PySide2) bindings. The following table represents the python environments we test in our CI system. Our CI system uses Ubuntu 18.04, Windows Server 2019, and macOS 10.15 base images.
| Python Version | PyQt4 | PySide | PyQt5-5.6 | PySide2-5.6 | PyQt5-5.9 | PySide2-5.9 | PyQt5-5.12 | PySide2 5.12 | | Qt-Bindings | Python 2.7 | Python 3.6 | Python 3.7 | Python 3.8 |
| :-------------- | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | | :----------- | :----------------: | :----------------: | :----------------: | :----------------: |
| 2.7 | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | | PyQt-4 | :white_check_mark: | :x: | :x: | :x: |
| 3.5 | :x: | :x: | :white_check_mark: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: | | PySide1 | :white_check_mark: | :x: | :x: | :x: |
| 3.6 | :x: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | PyQt-5.9 | :x: | :white_check_mark: | :x: | :x: |
| 3.7 | :x: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | PySide2-5.13 | :x: | :x: | :white_check_mark: | :x: |
| PyQt-5.14 | :x: | :x: | :x: | :white_check_mark: |
* pyqtgraph has had some incompatabilities with PySide2-5.6, and we recommend you avoid those bindings if possible * pyqtgraph has had some incompatabilities with PySide2-5.6, and we recommend you avoid those bindings if possible
* on macOS with Python 2.7 and Qt4 bindings (PyQt4 or PySide) the openGL related visualizations do not work * on macOS with Python 2.7 and Qt4 bindings (PyQt4 or PySide) the openGL related visualizations do not work

View File

@ -17,13 +17,14 @@ pr:
variables: variables:
OFFICIAL_REPO: 'pyqtgraph/pyqtgraph' OFFICIAL_REPO: 'pyqtgraph/pyqtgraph'
DEFAULT_MERGE_BRANCH: 'develop' DEFAULT_MERGE_BRANCH: 'develop'
disable.coverage.autogenerate: 'true'
stages: stages:
- stage: "pre_test" - stage: "pre_test"
jobs: jobs:
- job: check_diff_size - job: check_diff_size
pool: pool:
vmImage: 'Ubuntu 16.04' vmImage: 'Ubuntu 18.04'
steps: steps:
- bash: | - bash: |
git config --global advice.detachedHead false git config --global advice.detachedHead false
@ -56,7 +57,7 @@ stages:
- job: "style_check" - job: "style_check"
pool: pool:
vmImage: "Ubuntu 16.04" vmImage: "Ubuntu 18.04"
steps: steps:
- task: UsePythonVersion@0 - task: UsePythonVersion@0
inputs: inputs:
@ -69,11 +70,11 @@ stages:
- job: "build_wheel" - job: "build_wheel"
pool: pool:
vmImage: 'Ubuntu 16.04' vmImage: 'Ubuntu 18.04'
steps: steps:
- task: UsePythonVersion@0 - task: UsePythonVersion@0
inputs: inputs:
versionSpec: 3.7 versionSpec: 3.8
- script: | - script: |
python -m pip install setuptools wheel python -m pip install setuptools wheel
python setup.py bdist_wheel --universal python setup.py bdist_wheel --universal
@ -87,12 +88,12 @@ stages:
- template: azure-test-template.yml - template: azure-test-template.yml
parameters: parameters:
name: linux name: linux
vmImage: 'Ubuntu 16.04' vmImage: 'Ubuntu 18.04'
- template: azure-test-template.yml - template: azure-test-template.yml
parameters: parameters:
name: windows name: windows
vmImage: 'vs2017-win2016' vmImage: 'windows-2019'
- template: azure-test-template.yml - template: azure-test-template.yml
parameters: parameters:
name: macOS name: macOS
vmImage: 'macOS-10.13' vmImage: 'macOS-10.15'

View File

@ -22,17 +22,13 @@ jobs:
python.version: "3.6" python.version: "3.6"
qt.bindings: "pyqt" qt.bindings: "pyqt"
install.method: "conda" install.method: "conda"
Python36-PySide2-5.9:
python.version: "3.6"
qt.bindings: "pyside2"
install.method: "conda"
Python37-PyQt-5.13:
python.version: '3.7'
qt.bindings: "PyQt5"
install.method: "pip"
Python37-PySide2-5.13: Python37-PySide2-5.13:
python.version: "3.7" python.version: "3.7"
qt.bindings: "PySide2" qt.bindings: "pyside2"
install.method: "conda"
Python38-PyQt-5.14:
python.version: '3.8'
qt.bindings: "PyQt5"
install.method: "pip" install.method: "pip"
steps: steps:
@ -75,22 +71,10 @@ jobs:
if [ $(agent.os) == 'Linux' ] if [ $(agent.os) == 'Linux' ]
then then
echo "##vso[task.prependpath]$CONDA/bin" echo "##vso[task.prependpath]$CONDA/bin"
if [ $(python.version) == '2.7' ]
then
echo "Grabbing Older Miniconda"
wget https://repo.anaconda.com/miniconda/Miniconda2-4.6.14-Linux-x86_64.sh -O Miniconda.sh
bash Miniconda.sh -b -p $CONDA -f
fi
elif [ $(agent.os) == 'Darwin' ] elif [ $(agent.os) == 'Darwin' ]
then then
sudo chown -R $USER $CONDA sudo chown -R $USER $CONDA
echo "##vso[task.prependpath]$CONDA/bin" echo "##vso[task.prependpath]$CONDA/bin"
if [ $(python.version) == '2.7' ]
then
echo "Grabbing Older Miniconda"
wget https://repo.anaconda.com/miniconda/Miniconda2-4.6.14-MacOSX-x86_64.sh -O Miniconda.sh
bash Miniconda.sh -b -p $CONDA -f
fi
elif [ $(agent.os) == 'Windows_NT' ] elif [ $(agent.os) == 'Windows_NT' ]
then then
echo "##vso[task.prependpath]$CONDA/Scripts" echo "##vso[task.prependpath]$CONDA/Scripts"
@ -99,33 +83,35 @@ jobs:
fi fi
displayName: 'Add Conda To $PATH' displayName: 'Add Conda To $PATH'
condition: eq(variables['install.method'], 'conda' ) condition: eq(variables['install.method'], 'conda' )
continueOnError: false
- bash: | - bash: |
if [ $(install.method) == "conda" ] if [ $(install.method) == "conda" ]
then then
conda create --name test-environment-$(python.version) python=$(python.version) --yes conda update --all --yes --quiet
echo "Conda Info:" conda create --name test-environment-$(python.version) python=$(python.version) --yes --quiet
conda info
echo "Installing qt-bindings"
source activate test-environment-$(python.version) source activate test-environment-$(python.version)
conda config --env --set always_yes true
if [ $(agent.os) == "Linux" ] && [ $(python.version) == "2.7" ] if [ $(python.version) == '2.7' ]
then then
conda install $(qt.bindings) --yes conda config --set restore_free_channel true
else
conda install -c conda-forge $(qt.bindings) --yes
fi fi
echo "Installing remainder of dependencies" if [ $(qt.bindings) == "pyside2" ] || ([ $(qt.bindings) == 'pyside' ] && [ $(agent.os) == 'Darwin' ])
conda install -c conda-forge numpy scipy six pyopengl h5py --yes then
conda config --prepend channels conda-forge
fi
conda info
conda install $(qt.bindings) numpy scipy pyopengl h5py six --yes --quiet
else else
pip install $(qt.bindings) numpy scipy pyopengl six h5py pip install $(qt.bindings) numpy scipy pyopengl h5py six
fi fi
echo "" pip install pytest pytest-cov coverage pytest-xdist
pip install pytest pytest-xdist pytest-cov coverage
if [ $(python.version) == "2.7" ] if [ $(python.version) == "2.7" ]
then then
pip install pytest-faulthandler==1.6.0 pip install pytest-faulthandler==1.6.0
export PYTEST_ADDOPTS="--faulthandler-timeout=15" export PYTEST_ADDOPTS="--faulthandler-timeout=15"
else
pip install pytest pytest-cov coverage
fi fi
displayName: "Install Dependencies" displayName: "Install Dependencies"
@ -180,9 +166,10 @@ jobs:
mkdir -p "$SCREENSHOT_DIR" mkdir -p "$SCREENSHOT_DIR"
# echo "If Screenshots are generated, they may be downloaded from:" # echo "If Screenshots are generated, they may be downloaded from:"
# echo "https://dev.azure.com/pyqtgraph/pyqtgraph/_apis/build/builds/$(Build.BuildId)/artifacts?artifactName=Screenshots&api-version=5.0" # echo "https://dev.azure.com/pyqtgraph/pyqtgraph/_apis/build/builds/$(Build.BuildId)/artifacts?artifactName=Screenshots&api-version=5.0"
pytest . -sv \ pytest . -v \
-n 1 \
--junitxml=junit/test-results.xml \ --junitxml=junit/test-results.xml \
-n 1 --cov pyqtgraph --cov-report=xml --cov-report=html --cov pyqtgraph --cov-report=xml --cov-report=html
displayName: 'Unit tests' displayName: 'Unit tests'
env: env:
AZURE: 1 AZURE: 1

View File

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import print_function, division, absolute_import from __future__ import print_function, division, absolute_import
from pyqtgraph import Qt
from . import utils from . import utils
from collections import namedtuple from collections import namedtuple
from pyqtgraph import Qt
import errno import errno
import importlib import importlib
import itertools import itertools
@ -150,6 +150,7 @@ conditionalExamples = {
) )
} }
@pytest.mark.skipif(Qt.QT_LIB == "PySide2" and "Qt.QtVersion.startswith('5.14')", reason="new PySide2 doesn't have loadUi functionality")
@pytest.mark.parametrize( @pytest.mark.parametrize(
"frontend, f", "frontend, f",
[ [

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from ..Qt import QtGui, QtCore from ..Qt import QtGui, QtCore
from ..python2_3 import asUnicode from ..python2_3 import asUnicode
import numpy as np import numpy as np
@ -921,7 +922,7 @@ class AxisItem(GraphicsWidget):
p2[axis] += tickLength*tickDir p2[axis] += tickLength*tickDir
tickPen = self.pen() tickPen = self.pen()
color = tickPen.color() color = tickPen.color()
color.setAlpha(lineAlpha) color.setAlpha(int(lineAlpha))
tickPen.setColor(color) tickPen.setColor(color)
tickSpecs.append((tickPen, Point(p1), Point(p2))) tickSpecs.append((tickPen, Point(p1), Point(p2)))
profiler('compute ticks') profiler('compute ticks')
@ -1078,7 +1079,7 @@ class AxisItem(GraphicsWidget):
p.setFont(self.tickFont) p.setFont(self.tickFont)
p.setPen(self.textPen()) p.setPen(self.textPen())
for rect, flags, text in textSpecs: for rect, flags, text in textSpecs:
p.drawText(rect, flags, text) p.drawText(rect, int(flags), text)
profiler('draw text') profiler('draw text')

View File

@ -654,7 +654,7 @@ class GradientEditorItem(TickSliderItem):
s = s1 * (1.-f) + s2 * f s = s1 * (1.-f) + s2 * f
v = v1 * (1.-f) + v2 * f v = v1 * (1.-f) + v2 * f
c = QtGui.QColor() c = QtGui.QColor()
c.setHsv(h,s,v) c.setHsv(*map(int, [h,s,v]))
if toQColor: if toQColor:
return c return c
else: else:

View File

@ -153,7 +153,7 @@ class GridItem(UIGraphicsItem):
continue continue
ppl = dim[ax] / nl[ax] ppl = dim[ax] / nl[ax]
c = np.clip(5.*(ppl-3), 0., 50.) c = np.clip(5 * (ppl-3), 0., 50.).astype(int)
linePen = self.opts['pen'] linePen = self.opts['pen']
lineColor = self.opts['pen'].color() lineColor = self.opts['pen'].color()

View File

@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-
import sys import sys
import numpy as np import numpy as np
import pytest import pytest
import pyqtgraph as pg import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtTest from pyqtgraph.Qt import QtCore, QtTest
from pyqtgraph.tests import assertImageApproved, mouseMove, mouseDrag, mouseClick, TransposedImageItem, resizeWindow from pyqtgraph.tests import assertImageApproved, mouseMove, mouseDrag, mouseClick, TransposedImageItem, resizeWindow
import pytest
app = pg.mkQApp() app = pg.mkQApp()
def test_getArrayRegion(transpose=False): def test_getArrayRegion(transpose=False):
pr = pg.PolyLineROI([[0, 0], [27, 0], [0, 28]], closed=True) pr = pg.PolyLineROI([[0, 0], [27, 0], [0, 28]], closed=True)
pr.setPos(1, 1) pr.setPos(1, 1)
@ -33,7 +33,6 @@ def test_getArrayRegion(transpose=False):
finally: finally:
pg.setConfigOptions(imageAxisOrder=origMode) pg.setConfigOptions(imageAxisOrder=origMode)
def test_getArrayRegion_axisorder(): def test_getArrayRegion_axisorder():
test_getArrayRegion(transpose=True) test_getArrayRegion(transpose=True)
@ -135,7 +134,7 @@ def check_getArrayRegion(roi, name, testResize=True, transpose=False):
img2.setImage(rgn[0, ..., 0]) img2.setImage(rgn[0, ..., 0])
app.processEvents() app.processEvents()
# on windows, one edge of one ROI handle is shifted slightly; letting this slide with pxCount=10 # on windows, one edge of one ROI handle is shifted slightly; letting this slide with pxCount=10
if sys.platform == 'win32' and pg.Qt.QT_LIB in ('PyQt4', 'PySide'): if pg.Qt.QT_LIB in {'PyQt4', 'PySide'}:
pxCount = 10 pxCount = 10
else: else:
pxCount=-1 pxCount=-1

View File

@ -367,8 +367,10 @@ def test_eq():
d1 = {'x': 1, 'y': np.nan, 3: ['a', np.nan, a3, 7, 2.3], 4: a4} d1 = {'x': 1, 'y': np.nan, 3: ['a', np.nan, a3, 7, 2.3], 4: a4}
d2 = deepcopy(d1) d2 = deepcopy(d1)
assert eq(d1, d2) assert eq(d1, d2)
assert eq(OrderedDict(d1), OrderedDict(d2)) d1_ordered = OrderedDict(d1)
assert not eq(OrderedDict(d1), d2) d2_ordered = deepcopy(d1_ordered)
assert eq(d1_ordered, d2_ordered)
assert not eq(d1_ordered, d2)
items = list(d1.items()) items = list(d1.items())
assert not eq(OrderedDict(items), OrderedDict(reversed(items))) assert not eq(OrderedDict(items), OrderedDict(reversed(items)))

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import pyqtgraph as pg import pyqtgraph as pg
import gc, os import gc, os
import pytest import pytest
@ -14,6 +15,7 @@ def test_isQObjectAlive():
@pytest.mark.skipif(pg.Qt.QT_LIB == 'PySide', reason='pysideuic does not appear to be ' @pytest.mark.skipif(pg.Qt.QT_LIB == 'PySide', reason='pysideuic does not appear to be '
'packaged with conda') 'packaged with conda')
@pytest.mark.skipif(pg.Qt.QT_LIB == "PySide2" and "pg.Qt.QtVersion.startswith('5.14')", reason="new PySide2 doesn't have loadUi functionality")
def test_loadUiType(): def test_loadUiType():
path = os.path.dirname(__file__) path = os.path.dirname(__file__)
formClass, baseClass = pg.Qt.loadUiType(os.path.join(path, 'uictest.ui')) formClass, baseClass = pg.Qt.loadUiType(os.path.join(path, 'uictest.ui'))

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
""" """
Test for unwanted reference cycles Test for unwanted reference cycles
@ -9,9 +10,7 @@ import six
import pytest import pytest
app = pg.mkQApp() app = pg.mkQApp()
skipreason = ('unclear why test is failing on python 3. skipping until someone ' skipreason = ('This test is failing on pyside and pyside2 for an unknown reason.')
'has time to fix it. Or pyside is being used. This test is '
'failing on pyside for an unknown reason too.')
def assert_alldead(refs): def assert_alldead(refs):
for ref in refs: for ref in refs:
@ -36,11 +35,10 @@ def mkrefs(*objs):
obj = [obj] obj = [obj]
for o in obj: for o in obj:
allObjs[id(o)] = o allObjs[id(o)] = o
return [weakref.ref(obj) for obj in allObjs.values()]
return map(weakref.ref, allObjs.values())
@pytest.mark.skipif(six.PY3 or pg.Qt.QT_LIB == 'PySide', reason=skipreason) @pytest.mark.skipif(pg.Qt.QT_LIB in {'PySide', 'PySide2'}, reason=skipreason)
def test_PlotWidget(): def test_PlotWidget():
def mkobjs(*args, **kwds): def mkobjs(*args, **kwds):
w = pg.PlotWidget(*args, **kwds) w = pg.PlotWidget(*args, **kwds)
@ -58,7 +56,7 @@ def test_PlotWidget():
for i in range(5): for i in range(5):
assert_alldead(mkobjs()) assert_alldead(mkobjs())
@pytest.mark.skipif(six.PY3 or pg.Qt.QT_LIB == 'PySide', reason=skipreason) @pytest.mark.skipif(pg.Qt.QT_LIB in {'PySide', 'PySide2'}, reason=skipreason)
def test_ImageView(): def test_ImageView():
def mkobjs(): def mkobjs():
iv = pg.ImageView() iv = pg.ImageView()
@ -66,12 +64,12 @@ def test_ImageView():
iv.setImage(data) iv.setImage(data)
return mkrefs(iv, iv.imageItem, iv.view, iv.ui.histogram, data) return mkrefs(iv, iv.imageItem, iv.view, iv.ui.histogram, data)
for i in range(5): for i in range(5):
gc.collect()
assert_alldead(mkobjs()) assert_alldead(mkobjs())
@pytest.mark.skipif(six.PY3 or pg.Qt.QT_LIB == 'PySide', reason=skipreason) @pytest.mark.skipif(pg.Qt.QT_LIB in {'PySide', 'PySide2'}, reason=skipreason)
def test_GraphicsWindow(): def test_GraphicsWindow():
def mkobjs(): def mkobjs():
w = pg.GraphicsWindow() w = pg.GraphicsWindow()

View File

@ -12,4 +12,8 @@ filterwarnings =
ignore:numpy.ufunc size changed, may indicate binary incompatibility.*:RuntimeWarning ignore:numpy.ufunc size changed, may indicate binary incompatibility.*:RuntimeWarning
# Warnings generated from PyQt5.9 # Warnings generated from PyQt5.9
ignore:This method will be removed in future versions. Use 'tree.iter\(\)' or 'list\(tree.iter\(\)\)' instead.:PendingDeprecationWarning ignore:This method will be removed in future versions. Use 'tree.iter\(\)' or 'list\(tree.iter\(\)\)' instead.:PendingDeprecationWarning
ignore:'U' mode is deprecated\nplugin = open\(filename, 'rU'\):DeprecationWarning ignore:.*'U' mode is deprecated.*:DeprecationWarning
# py36/pyside2_512 specific issue
ignore:split\(\) requires a non-empty pattern match\.:FutureWarning
# pyqtgraph specific warning we want to ignore during testing
ignore:Visible window deleted. To prevent this, store a reference to the window object.

43
tox.ini
View File

@ -1,22 +1,16 @@
[tox] [tox]
envlist = envlist =
; qt 5.12.x ; qt latest
py{27,37}-pyside2-pip py{37,38}-{pyqt5,pyside2}_latest
py{35,37}-pyqt5-pip
; qt 5.9.7 ; qt 5.12.x (LTS)
py{27,37}-pyqt5-conda py{36,37}-{pyqt5,pyside2}_512
py{27,37}-pyside2-conda
; qt 5.6.2 ; qt 5.9.7 (LTS)
py35-pyqt5-conda py36-{pyqt5,pyside2}_59_conda
; consider dropping support...
; py35-pyside2-conda
; qt 4.8.7 ; qt 4.8.7
py{27,36}-pyqt4-conda py27-{pyqt4,pyside}_conda
py{27,36}-pyside-conda
[base] [base]
deps = deps =
@ -30,21 +24,26 @@ deps =
[testenv] [testenv]
passenv = DISPLAY XAUTHORITY passenv = DISPLAY XAUTHORITY
setenv = PYTHONWARNINGS=ignore:DEPRECATION::pip._internal.cli.base_command
deps= deps=
{[base]deps} {[base]deps}
pytest-cov pytest-cov
pytest-xdist h5py
pyside2-pip: pyside2 pyside2_512: pyside2>=5.12,<5.13
pyqt5-pip: pyqt5 pyqt5_512: pyqt5>=5.12,<5.13
pyside2_latest: pyside2
pyqt5_latest: pyqt5
conda_deps= conda_deps=
pyside2-conda: pyside2 pyside2_59_conda: pyside2=5.9
pyside-conda: pyside pyqt5_59_conda: pyqt=5.9
pyqt5-conda: pyqt pyqt4_conda: pyqt=4
pyqt4-conda: pyqt=4 pyside_conda: pyside
conda_channels= conda_channels=
conda-forge conda-forge
free
commands= commands=
python -c "import pyqtgraph as pg; pg.systemInfo()" python -c "import pyqtgraph as pg; pg.systemInfo()"
pytest {posargs:.} pytest {posargs:}