test: fixing tests [wip] (#164)

This commit is contained in:
Talley Lambert
2023-05-19 20:43:52 -04:00
committed by GitHub
parent ca4a1ecb20
commit 1fb46854d4
8 changed files with 34 additions and 146 deletions

View File

@@ -19,39 +19,20 @@ jobs:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.9", "3.10"]
backend: [pyqt5, pyside2]
include:
# pyqt6 and pyside6 on latest platforms
- python-version: "3.10"
platform: ubuntu-latest
python-version: ["3.8", "3.9", "3.10", "3.11"]
backend: [pyqt5, pyside2, pyqt6]
exclude:
# Abort (core dumped) on linux pyqt6, unknown reason
- platform: ubuntu-latest
backend: pyqt6
- python-version: "3.10"
platform: windows-latest
backend: pyqt6
- python-version: "3.10"
platform: macos-latest
backend: pyqt6
# also take screenshots
- python-version: "3.10"
platform: ubuntu-latest
backend: pyside6
screenshot: 1
- python-version: "3.10"
platform: windows-latest
backend: pyside6
screenshot: 1
- python-version: "3.10"
platform: macos-latest
backend: pyside6
screenshot: 1
# lack of wheels for pyside2/py3.11
- python-version: "3.11"
backend: pyside2
- python-version: "3.11"
platform: ubuntu-latest
backend: pyqt6
- python-version: "3.11"
platform: windows-latest
backend: pyqt5
include:
- python-version: "3.10"
platform: macos-latest
backend: pyside6
- python-version: "3.11"
platform: macos-latest
backend: pyside6
@@ -63,16 +44,17 @@ jobs:
- python-version: 3.7
platform: windows-latest
backend: pyside2
# legacy Qt
- python-version: 3.7
- python-version: 3.8
platform: ubuntu-latest
backend: pyqt512
- python-version: 3.7
backend: "pyqt5==5.12.*"
- python-version: 3.8
platform: ubuntu-latest
backend: pyqt513
- python-version: 3.7
backend: "pyqt5==5.13.*"
- python-version: 3.8
platform: ubuntu-latest
backend: pyqt514
backend: "pyqt5==5.14.*"
steps:
- name: Cancel Previous Runs
@@ -96,40 +78,17 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools tox tox-gh-actions
python -m pip install -e .[test]
python -m pip install ${{ matrix.backend }}
- name: Test with tox
- name: Test
uses: aganders3/headless-gui@v1.2
timeout-minutes: 3
with:
run: python -m tox
env:
PLATFORM: ${{ matrix.platform }}
BACKEND: ${{ matrix.backend }}
run: python -m pytest --color=yes --cov=superqt --cov-report=xml
- name: Coverage
uses: codecov/codecov-action@v3
- name: Install for screenshots
if: matrix.screenshot
run: pip install -e .[${{ matrix.backend }}]
- name: Screenshots (Linux)
if: runner.os == 'Linux' && matrix.screenshot
uses: aganders3/headless-gui@v1.2
with:
run: python examples/demo_widget.py -snap
- name: Screenshots (macOS/Win)
if: runner.os != 'Linux' && matrix.screenshot
run: python examples/demo_widget.py -snap
- uses: actions/upload-artifact@v3
if: matrix.screenshot
with:
name: screenshots ${{ runner.os }}
path: screenshots
test_old_qtpy:
name: qtpy minreq
runs-on: ubuntu-latest

View File

@@ -48,5 +48,4 @@ All widgets should try to match the native Qt API as much as possible:
## Testing
Tests can be run in the current environment with `pytest`. Or, to run tests
against all supported python & Qt versions, run `tox`.
Tests can be run in the current environment with `pytest`.

View File

@@ -48,7 +48,7 @@ dependencies = [
# extras
# https://peps.python.org/pep-0621/#dependencies-optional-dependencies
[project.optional-dependencies]
test = ["pint", "pytest", "pytest-cov", "pytest-qt", "tox", "tox-conda"]
test = ["pint", "pytest", "pytest-cov", "pytest-qt"]
dev = [
"black",
"ipython",
@@ -169,7 +169,6 @@ ignore = [
".github_changelog_generator",
".pre-commit-config.yaml",
"tests/**/*",
"tox.ini",
"src/superqt/_version.py",
"mkdocs.yml",
"docs/**/*",

View File

@@ -1,4 +1,4 @@
from typing import Generic, List, Optional, Sequence, Tuple, TypeVar, Union
from typing import List, Optional, Sequence, Tuple, TypeVar, Union
from qtpy import QtGui
from qtpy.QtCore import Property, QEvent, QPoint, QPointF, QRect, QRectF, Qt, Signal
@@ -17,7 +17,7 @@ _T = TypeVar("_T")
SC_BAR = QStyle.SubControl.SC_ScrollBarSubPage
class _GenericRangeSlider(_GenericSlider[Tuple], Generic[_T]):
class _GenericRangeSlider(_GenericSlider):
"""MultiHandle Range Slider widget.
Same API as QSlider, but `value`, `setValue`, `sliderPosition`, and

View File

@@ -21,7 +21,7 @@ QRangeSlider.
"""
import os
import platform
from typing import Generic, TypeVar
from typing import TypeVar
from qtpy import QT_VERSION, QtGui
from qtpy.QtCore import QEvent, QPoint, QPointF, QRect, Qt, Signal
@@ -58,7 +58,7 @@ USE_MAC_SLIDER_PATCH = (
)
class _GenericSlider(QSlider, Generic[_T]):
class _GenericSlider(QSlider):
_fvalueChanged = Signal(int)
_fsliderMoved = Signal(int)
_frangeChanged = Signal(int, int)

View File

@@ -27,11 +27,11 @@ class _FloatMixin:
return float(value)
class QDoubleSlider(_FloatMixin, _GenericSlider[float]):
class QDoubleSlider(_FloatMixin, _GenericSlider):
pass
class QIntSlider(_IntMixin, _GenericSlider[int]):
class QIntSlider(_IntMixin, _GenericSlider):
# mostly just an example... use QSlider instead.
valueChanged = Signal(int)

View File

@@ -7,10 +7,10 @@ from qtpy.QtCore import Qt
from superqt import QRangeSlider
from superqt.sliders._generic_range_slider import SC_BAR, SC_HANDLE, SC_NONE
NOT_LINUX = platform.system() != "Linux"
NOT_PYSIDE2 = API_NAME != "PySide2"
LINUX = platform.system() == "Linux"
NOT_PYQT6 = API_NAME != "PyQt6"
skipmouse = pytest.mark.skipif(NOT_LINUX or NOT_PYSIDE2, reason="mouse tests finicky")
skipmouse = pytest.mark.skipif(LINUX or NOT_PYQT6, reason="mouse tests finicky")
@pytest.mark.parametrize("orientation", ["Horizontal", "Vertical"])

69
tox.ini
View File

@@ -1,69 +0,0 @@
[tox]
envlist = py{37,38,39,310,311}-{linux,macos,windows}-{pyqt5,pyside2,pyqt6,pyside6},py37-linux-{pyqt512,pyqt513,pyqt514}
toxworkdir=/tmp/.tox
isolated_build=True
[coverage:report]
exclude_lines =
pragma: no cover
if TYPE_CHECKING:
\.\.\.
except ImportError*
raise NotImplementedError()
omit =
superqt/_version.py
*_tests*
[gh-actions]
python =
3.6: py36
3.7: py37
3.8: py38
3.9: py39
3.10: py310
3.11: py311
[gh-actions:env]
PLATFORM =
ubuntu-latest: linux
ubuntu-16.04: linux
ubuntu-18.04: linux
ubuntu-20.04: linux
windows-latest: windows
macos-latest: macos
macos-11.0: macos
BACKEND =
pyqt5: pyqt5
pyside2: pyside2
pyqt6: pyqt6
pyside6: pyside6
pyqt512: pyqt512
pyqt513: pyqt513
pyqt514: pyqt514
[testenv]
platform =
macos: darwin
linux: linux
windows: win32
passenv =
CI
GITHUB_ACTIONS
DISPLAY
XAUTHORITY
deps =
pyqt512: pyqt5==5.12.*
pyside512: pyside2==5.12.*
pyqt513: pyqt5==5.13.*
pyside513: pyside2==5.13.*
pyqt514: pyqt5==5.14.*
pyside514: pyside2==5.14.*
extras =
test
pyqt5: pyqt5
pyside2: pyside2
pyqt6: pyqt6
pyside6: pyside6
commands_pre =
pyqt6,pyside6: pip install -U pytest-qt@git+https://github.com/pytest-dev/pytest-qt.git
commands = pytest --color=yes --cov=superqt --cov-report=xml -v {posargs}