Merge pull request #918 from j9ac9k/small-test-fixes

README, CONTRIBUTING changes, slight changes to azure CI template and tox.ini
This commit is contained in:
Ogi Moore 2019-06-12 23:05:53 -07:00 committed by GitHub
commit 7b47337eaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 154 additions and 116 deletions

69
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,69 @@
# Contributing to PyQtGraph
Contributions to pyqtgraph are welcome!
Please use the following guidelines when preparing changes:
## Submitting Code Changes
* 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.
* 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.
## 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.
* Documentation is generated with sphinx; please check that docstring changes compile correctly
## Style guidelines
* PyQtGraph prefers PEP8 for most style issues, but this is not enforced rigorously as long as the code is clean and readable.
* Use `python setup.py style` to see whether your code follows the mandatory style guidelines checked by flake8.
* Exception 1: All variable names should use camelCase rather than underscore_separation. This is done for consistency with Qt
* Exception 2: Function docstrings use ReStructuredText tables for describing arguments:
```text
============== ========================================================
**Arguments:**
argName1 (type) Description of argument
argName2 (type) Description of argument. Longer descriptions must
be wrapped within the column guidelines defined by the
"====" header and footer.
============== ========================================================
```
QObject subclasses that implement new signals should also describe
these in a similar table.
## Testing Setting up a test environment
### Dependencies
* tox
* tox-conda
* pytest
* pytest-cov
* pytest-xdist
* pytest-faulthandler
* Optional: pytest-xvfb
### Tox
As PyQtGraph supports a wide array of Qt-bindings, and python versions, we make use of `tox` to test against most of the configurations in our test matrix. As some of the qt-bindings are only installable via `conda`, `conda` needs to be in your `PATH`, and we utilize the `tox-conda` plugin.
* Tests for a module should ideally cover all code in that module, i.e., statement coverage should be at 100%.
* To measure the test coverage, un `pytest --cov -n 4` to run the test suite with coverage on 4 cores.
### Continous Integration
For our Continuous Integration, we utilize Azure Pipelines. On each OS, we test the following 6 configurations
* 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,58 +0,0 @@
Contributions to pyqtgraph are welcome!
Please use the following guidelines when preparing changes:
* 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.
* 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.
* Writing proper documentation and unit tests is highly encouraged. PyQtGraph
uses nose / py.test 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.
* Style guidelines:
* PyQtGraph prefers PEP8 for most style issues, but this is not enforced
rigorously as long as the code is clean and readable.
* Use `python setup.py style` to see whether your code follows
the mandatory style guidelines checked by flake8.
* Exception 1: All variable names should use camelCase rather than
underscore_separation. This is done for consistency with Qt
* Exception 2: Function docstrings use ReStructuredText tables for
describing arguments:
```
============== ========================================================
**Arguments:**
argName1 (type) Description of argument
argName2 (type) Description of argument. Longer descriptions must
be wrapped within the column guidelines defined by the
"====" header and footer.
============== ========================================================
```
QObject subclasses that implement new signals should also describe
these in a similar table.
* Setting up a test environment.
Tests for a module should ideally cover all code in that module,
i.e., statement coverage should be at 100%.
To measure the test coverage, install py.test, pytest-cov and pytest-xdist.
Then run 'py.test --cov -n 4' to run the test suite with coverage on 4 cores.

View File

@ -1,12 +1,13 @@
[![Build Status](https://travis-ci.org/pyqtgraph/pyqtgraph.svg?branch=develop)](https://travis-ci.org/pyqtgraph/pyqtgraph)
[![codecov.io](http://codecov.io/github/pyqtgraph/pyqtgraph/coverage.svg?branch=develop)](http://codecov.io/github/pyqtgraph/pyqtgraph?branch=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
========= =========
A pure-Python graphics library for PyQt/PySide A pure-Python graphics library for PyQt/PySide/PyQt5/PySide2
Copyright 2017 Luke Campagnola, University of North Carolina at Chapel Hill Copyright 2019 Luke Campagnola, University of North Carolina at Chapel Hill
<http://www.pyqtgraph.org> <http://www.pyqtgraph.org>
@ -15,15 +16,32 @@ Despite being written entirely in python, the library is fast due to its
heavy leverage of numpy for number crunching, Qt's GraphicsView framework for heavy leverage of numpy for number crunching, Qt's GraphicsView framework for
2D display, and OpenGL for 3D display. 2D display, and OpenGL for 3D display.
Requirements Requirements
------------ ------------
* PyQt 4.7+, PySide, PyQt5, or PySide2 * PyQt 4.8+, PySide, PyQt5, or PySide2
* python 2.7, or 3.x * python 2.7, or 3.x
* NumPy * Required
* For 3D graphics: pyopengl and qt-opengl * `numpy`, `scipy`
* Known to run on Windows, Linux, and Mac. * Optional
* `pyopengl` for 3D graphics
* `pyqtgraph.opengl` will be depreciated in a future version and replaced with `VisPy`
* `hdf5` for large hdf5 binary format support
* Known to run on Windows, Linux, and macOS.
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.
| Python Version | PyQt4 | PySide | PyQt5-5.6 | PySide2-5.6 | PyQt5-5.9 | PySide2-5.9 | PyQt5-5.12 | PySide2 5.12 |
| :-------------- | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: |
| 2.7 | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
| 3.5 | :x: | :x: | :white_check_mark: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: |
| 3.6 | :x: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| 3.7 | :x: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
* pyqtgraph has had some incompatabilities with PySide2-5.6, and we recommend you avoid those bindings if possible.
Support Support
------- -------
@ -36,7 +54,9 @@ Installation Methods
* From PyPI: * From PyPI:
* Last released version: `pip install pyqtgraph` * Last released version: `pip install pyqtgraph`
* Latest development version: `pip install git+https://github.com/pyqtgraph/pyqtgraph` * Latest development version: `pip install git+https://github.com/pyqtgraph/pyqtgraph@develop`
* From conda
* Last released version: `conda install pyqtgraph`
* To install system-wide from source distribution: `python setup.py install` * To install system-wide from source distribution: `python setup.py install`
* Many linux package repositories have release versions. * Many linux package repositories have release versions.
* To use with a specific project, simply copy the pyqtgraph subdirectory * To use with a specific project, simply copy the pyqtgraph subdirectory
@ -49,16 +69,3 @@ Documentation
The easiest way to learn pyqtgraph is to browse through the examples; run `python -m pyqtgraph.examples` for a menu. The easiest way to learn pyqtgraph is to browse through the examples; run `python -m pyqtgraph.examples` for a menu.
The official documentation lives at http://pyqtgraph.org/documentation The official documentation lives at http://pyqtgraph.org/documentation
Testing
-------
To test the pyqtgraph library, clone the repository, and run `pytest pyqtgraph`. For more thurough testing, you can use `tox`, however the [tox-conda](https://github.com/tox-dev/tox-conda) plugin is required. Running `tox` on its own will run `pytest pyqtgraph -vv` on it's own, however if you want to run a specific test, you can run `tox -- pyqtgraph/exporters/tests/test_svg::test_plotscene` for example.
Dependencies include:
* pytest
* pytest-cov
* pytest-xdist
* tox
* tox-conda

View File

@ -10,20 +10,20 @@ jobs:
vmImage: ${{ parameters.vmImage }} vmImage: ${{ parameters.vmImage }}
strategy: strategy:
matrix: matrix:
Python27-Qt4: Python27-PyQt4-4.8:
python.version: '2.7' python.version: '2.7'
qt.bindings: "pyqt=4" qt.bindings: "pyqt=4"
install.method: "conda" install.method: "conda"
Python27-PySide: Python27-PySide-4.8:
python.version: '2.7' python.version: '2.7'
qt.bindings: "pyside" qt.bindings: "pyside"
install.method: "conda" install.method: "conda"
Python37-PyQt-5.9: Python36-PyQt-5.9:
python.version: "3.7" python.version: "3.6"
qt.bindings: "pyqt" qt.bindings: "pyqt"
install.method: "conda" install.method: "conda"
Python37-PySide2-5.6: Python36-PySide2-5.9:
python.version: "3.7" python.version: "3.6"
qt.bindings: "pyside2" qt.bindings: "pyside2"
install.method: "conda" install.method: "conda"
Python37-PyQt-5.12: Python37-PyQt-5.12:
@ -88,7 +88,6 @@ jobs:
then then
source activate test-environment-$(python.version) source activate test-environment-$(python.version)
fi fi
pip install setuptools wheel pip install setuptools wheel
python setup.py bdist_wheel python setup.py bdist_wheel
pip install dist/*.whl pip install dist/*.whl
@ -98,11 +97,11 @@ jobs:
inputs: inputs:
contents: 'dist/**' contents: 'dist/**'
targetFolder: $(Build.ArtifactStagingDirectory) targetFolder: $(Build.ArtifactStagingDirectory)
cleanTargetFolder: true # Optional cleanTargetFolder: true
displayName: "Copy Distributions To Artifacts" displayName: "Copy Binary Wheel Distribution To Artifacts"
- task: PublishBuildArtifacts@1 - task: PublishBuildArtifacts@1
displayName: 'Publish Distributions' displayName: 'Publish Binary Wheel'
condition: always() condition: always()
inputs: inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)/dist pathtoPublish: $(Build.ArtifactStagingDirectory)/dist
@ -130,10 +129,18 @@ jobs:
pip list pip list
echo pyqtgraph system info echo pyqtgraph system info
python -c "import pyqtgraph as pg; pg.systemInfo()" python -c "import pyqtgraph as pg; pg.systemInfo()"
echo display information
if [ $(agent.os) == 'Linux' ]
then
export DISPLAY=:99.0
Xvfb :99 -screen 0 1920x1080x24 &
sleep 3
fi
python -m pyqtgraph.util.get_resolution
displayName: 'Debug Info' displayName: 'Debug Info'
continueOnError: false continueOnError: false
- bash: | - bash: |
if [ $(install.method) == "conda" ] if [ $(install.method) == "conda" ]
then then
source activate test-environment-$(python.version) source activate test-environment-$(python.version)
@ -141,10 +148,9 @@ 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"
python -m pytest -sv \ pytest . -sv \
--junitxml=junit/test-results.xml \ --junitxml=junit/test-results.xml \
--cov pyqtgraph --cov-report=xml --cov-report=html \ -n 1 --cov pyqtgraph --cov-report=xml --cov-report=html
--faulthandler-timeout=60
displayName: 'Unit tests' displayName: 'Unit tests'
env: env:
AZURE: 1 AZURE: 1

View File

@ -1,10 +0,0 @@
from .. import mkQApp
qApp = mkQApp()
def test_displayResolution():
desktop = qApp.desktop().screenGeometry()
width, height = desktop.width(), desktop.height()
print("\n\nDisplay Resolution Logged as {}x{}\n\n".format(width, height))
assert height > 0 and width > 0

View File

@ -1,7 +1,15 @@
from .. import mkQApp from .. import mkQApp
def test_screenInformation():
def getResolution():
qApp = mkQApp() qApp = mkQApp()
desktop = qApp.desktop().screenGeometry() desktop = qApp.desktop()
return (desktop.width(), desktop.height()) resolution = desktop.screenGeometry()
availableResolution = desktop.availableGeometry()
print("Screen resolution: {}x{}".format(resolution.width(), resolution.height()))
print("Available geometry: {}x{}".format(availableResolution.width(), availableResolution.height()))
print("Number of Screens: {}".format(desktop.screenCount()))
return None
if __name__ == "__main__":
test_screenInformation()

View File

@ -1,3 +1,14 @@
[pytest] [pytest]
xvfb_width = 1920
xvfb_height = 1080
# use this due to some issues with ndarray reshape errors on CI systems
xvfb_colordepth = 24 xvfb_colordepth = 24
addopts = --faulthandler-timeout=15
filterwarnings =
# comfortable skipping these warnings runtime warnings
# https://stackoverflow.com/questions/40845304/runtimewarning-numpy-dtype-size-changed-may-indicate-binary-incompatibility
ignore:numpy.ufunc size changed, may indicate binary incompatibility.*:RuntimeWarning
# Warnings generated from PyQt5.9
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

17
tox.ini
View File

@ -2,19 +2,22 @@
envlist = envlist =
; qt 5.12.x ; qt 5.12.x
py{27,37}-pyside2-pip py{27,37}-pyside2-pip
; qt 5.12.x
py{35,37}-pyqt5-pip py{35,37}-pyqt5-pip
; qt 5.9.7 ; qt 5.9.7
py{27,37}-pyqt5-conda py{27,37}-pyqt5-conda
py{27,37}-pyside2-conda
; qt 5.6.2 ; qt 5.6.2
py35-pyqt5-conda py35-pyqt5-conda
; qt 5.6.2 ; consider dropping support...
py{27,35,37}-pyside2-conda ; py35-pyside2-conda
; pyqt 4.11.4 / qt 4.8.7
; qt 4.8.7
py{27,36}-pyqt4-conda py{27,36}-pyqt4-conda
; pyside 1.2.4 / qt 4.8.7
py{27,36}-pyside-conda py{27,36}-pyside-conda
[base] [base]
deps = deps =
pytest pytest
@ -26,10 +29,12 @@ deps =
coverage coverage
[testenv] [testenv]
passenv = DISPLAY XAUTHORITY
deps= deps=
{[base]deps} {[base]deps}
pytest-cov pytest-cov
pytest-xdist pytest-xdist
pytest-faulthandler
pyside2-pip: pyside2 pyside2-pip: pyside2
pyqt5-pip: pyqt5 pyqt5-pip: pyqt5
@ -43,4 +48,4 @@ conda_channels=
conda-forge conda-forge
commands= commands=
python -c "import pyqtgraph as pg; pg.systemInfo()" python -c "import pyqtgraph as pg; pg.systemInfo()"
python -m pytest {posargs:pyqtgraph -svv} pytest {posargs:.}