From 1fb46854d43522ba69c2fd412c7a4466747211b7 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Fri, 19 May 2023 20:43:52 -0400 Subject: [PATCH] test: fixing tests [wip] (#164) --- .github/workflows/test_and_deploy.yml | 87 ++++++-------------- CONTRIBUTING.md | 3 +- pyproject.toml | 3 +- src/superqt/sliders/_generic_range_slider.py | 4 +- src/superqt/sliders/_generic_slider.py | 4 +- src/superqt/sliders/_sliders.py | 4 +- tests/test_sliders/test_slider.py | 6 +- tox.ini | 69 ---------------- 8 files changed, 34 insertions(+), 146 deletions(-) delete mode 100644 tox.ini diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 27ca66e..37d7e7a 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9fea0e3..3782896 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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`. diff --git a/pyproject.toml b/pyproject.toml index 25fecc4..f1f9e44 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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/**/*", diff --git a/src/superqt/sliders/_generic_range_slider.py b/src/superqt/sliders/_generic_range_slider.py index 9509af2..883571b 100644 --- a/src/superqt/sliders/_generic_range_slider.py +++ b/src/superqt/sliders/_generic_range_slider.py @@ -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 diff --git a/src/superqt/sliders/_generic_slider.py b/src/superqt/sliders/_generic_slider.py index 2535bfd..7b35a92 100644 --- a/src/superqt/sliders/_generic_slider.py +++ b/src/superqt/sliders/_generic_slider.py @@ -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) diff --git a/src/superqt/sliders/_sliders.py b/src/superqt/sliders/_sliders.py index f82a325..7564664 100644 --- a/src/superqt/sliders/_sliders.py +++ b/src/superqt/sliders/_sliders.py @@ -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) diff --git a/tests/test_sliders/test_slider.py b/tests/test_sliders/test_slider.py index 467551a..358b208 100644 --- a/tests/test_sliders/test_slider.py +++ b/tests/test_sliders/test_slider.py @@ -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"]) diff --git a/tox.ini b/tox.ini deleted file mode 100644 index ead7aaf..0000000 --- a/tox.ini +++ /dev/null @@ -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}