[Python-modules-commits] [pytest-qt] 01/07: New upstream version 2.2.0

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Sep 20 17:49:23 UTC 2017


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch master
in repository pytest-qt.

commit 9334eb32e6c3b02eb57e83dcce89619595c3dda8
Author: Ghislain Antony Vaillant <ghisvail at gmail.com>
Date:   Tue Sep 19 22:20:22 2017 +0200

    New upstream version 2.2.0
---
 .pydevproject                  |  1 +
 .travis.yml                    | 50 ++++++++++++------------
 CHANGELOG.rst                  |  8 ++++
 PKG-INFO                       | 11 ++++--
 README.rst                     |  9 +++--
 appveyor.yml                   | 78 +++++++++++++++++++++++++++----------
 docs/intro.rst                 |  5 ++-
 pytest_qt.egg-info/PKG-INFO    | 11 ++++--
 pytest_qt.egg-info/SOURCES.txt |  1 -
 pytestqt/_version.py           |  2 +-
 pytestqt/qt_compat.py          | 57 +++++++++++++++++++--------
 pytestqt/qtbot.py              |  2 +-
 scripts/install-qt.py          | 88 ------------------------------------------
 tests/test_basics.py           |  4 +-
 tests/test_logging.py          |  2 +
 tests/test_qtest_proxies.py    |  4 +-
 tests/test_wait_signal.py      | 16 ++++----
 17 files changed, 169 insertions(+), 180 deletions(-)

diff --git a/.pydevproject b/.pydevproject
index a946dfc..f062ff5 100644
--- a/.pydevproject
+++ b/.pydevproject
@@ -2,6 +2,7 @@
 <?eclipse-pydev version="1.0"?><pydev_project>
 <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
 <path>/${PROJECT_DIR_NAME}</path>
+<path>/${PROJECT_DIR_NAME}/tests</path>
 </pydev_pathproperty>
 <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
 <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
diff --git a/.travis.yml b/.travis.yml
index a6edbaf..8eb3266 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,14 +3,20 @@ sudo: required
 dist: trusty
 
 env:
- - PYTEST_QT_API=pyqt4   PYTHON=python2.7
- - PYTEST_QT_API=pyqt4v2 PYTHON=python2.7
- - PYTEST_QT_API=pyside  PYTHON=python2.7
+  global:
+      # used by ci-helpers
+      - CONDA_CHANNELS=conda-forge SETUP_XVFB=true  DEPS="pytest tox coveralls"
 
- - PYTEST_QT_API=pyqt4   PYTHON=python3.4
- - PYTEST_QT_API=pyqt4v2 PYTHON=python3.4
- - PYTEST_QT_API=pyside  PYTHON=python3.4
- - PYTEST_QT_API=pyqt5   PYTHON=python3.4
+  matrix:
+      - PYTEST_QT_API=pyqt4   PYQT_PACKAGE="pyqt=4.*" PYTHON_VERSION=2.7
+      - PYTEST_QT_API=pyqt4v2 PYQT_PACKAGE="pyqt=4.*" PYTHON_VERSION=2.7
+      - PYTEST_QT_API=pyside  PYQT_PACKAGE="pyside=1.*" PYTHON_VERSION=2.7
+
+      - PYTEST_QT_API=pyqt4   PYQT_PACKAGE="pyqt=4.*" PYTHON_VERSION=3.4
+      - PYTEST_QT_API=pyqt4v2 PYQT_PACKAGE="pyqt=4.*" PYTHON_VERSION=3.4
+      - PYTEST_QT_API=pyside  PYQT_PACKAGE="pyside=1.*" PYTHON_VERSION=3.4
+      - PYTEST_QT_API=pyqt5   PYQT_PACKAGE="pyqt=5.*" PYTHON_VERSION=3.4
+      - PYTEST_QT_API=pyside2   PYQT_PACKAGE="pyside2=2.*" PYTHON_VERSION=3.5
 
 install:
  - sudo apt-get update
@@ -18,30 +24,22 @@ install:
  # Xvfb / window manager
  - sudo apt-get install -y xvfb herbstluftwm
 
- # Qt
- - $PYTHON scripts/install-qt.py
-
- # Pip (3.4 does not have it by default)
- - wget https://bootstrap.pypa.io/get-pip.py
- - sudo $PYTHON get-pip.py
-
- # Dependencies
- - sudo $PYTHON -m pip install -U pytest tox coveralls
+ # Setup miniconda 
+ - git clone --depth 1 git://github.com/astropy/ci-helpers.git
+ - CONDA_DEPENDENCIES="${DEPS} ${PYQT_PACKAGE}" source ci-helpers/travis/setup_conda.sh
+ - source activate test && pip install -e .
 
- # pytest-qt
- - sudo $PYTHON setup.py develop
 
 before_script:
- - "export DISPLAY=:99.0"
- - start-stop-daemon --start --background --exec /usr/bin/Xvfb -- $DISPLAY -screen 0 1024x768x24
- - sleep 3 # give xvfb some time to start
  - "herbstluftwm &"
  - sleep 1
 
 script:
- - catchsegv coverage run --source=pytestqt -m pytest tests
- - sudo tox -e lint
- - sudo chmod -R a+rw .
+ - source activate test && catchsegv coverage run --source=pytestqt -m pytest -v tests
+ # for some reason tox doesn't get installed with a u+x flag
+ - | 
+     chmod u+x /home/travis/miniconda/envs/test/bin/tox 
+     /home/travis/miniconda/envs/test/bin/tox -e lint
 
 after_success:
  - coveralls
@@ -50,11 +48,11 @@ deploy:
   provider: pypi
   skip_upload_docs: true
   user: nicoddemus
+  distributions: sdist bdist_wheel
   password:
-    secure: Uj4XhkIUGE8CkE9mbP4y2wrp1s+jODkEi+wXCL1ZDhcCxxs3gjEOtAlqIXS/4PMLZcxeV2rXNGzGJ6n+i6Ruj2T1wfar7hmy2faaur6tcUDhEpXLkAl6DAKlMiZbEyT4C7OpunBoYmw8Gh/3kaDeGgz4FxEiJakAqzEmmeyFvFY=
+    secure: Fql0uLFWz+D6p36BUm+2WB5tjUiuCkOFpU68Dnycn5cIRqZQuBzfNNZPVGHgIUGNZ5rC+rJC+edEvJoF2AB9cQ7kz86SzZuQHdEOwsnR4KQw2tkD5fw2BqH4bQ56SQ+UHAsyQAuDkjShHTrwSTJrzShIE5Poma5BqmqC4mRSgbI=
   on:
     tags: true
-    distributions: sdist bdist_wheel
     repo: pytest-dev/pytest-qt
     condition: $PYTEST_QT_API = pyqt5
 
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 46c37b0..4ea6da1 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,3 +1,11 @@
+2.2.0
+-----
+
+- ``pytest-qt`` now supports `PySide2`_ thanks to `@rth`_!
+
+.. _PySide2: https://wiki.qt.io/PySide2
+.. _ at rth: https://github.com/rth
+
 2.1.2
 -----
 
diff --git a/PKG-INFO b/PKG-INFO
index 01a6584..45ae18f 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pytest-qt
-Version: 2.1.2
+Version: 2.2.0
 Summary: pytest support for PyQt and PySide applications
 Home-page: http://github.com/pytest-dev/pytest-qt
 Author: Bruno Oliveira
@@ -11,7 +11,7 @@ Description: =========
         =========
         
         pytest-qt is a `pytest`_ plugin that allows programmers to write tests
-        for `PySide`_ and `PyQt`_ applications.
+        for `PySide`_, `PySide2` and `PyQt`_ applications.
         
         The main usage is to use the `qtbot` fixture, responsible for handling `qApp` 
         creation as needed and provides methods to simulate user interaction, 
@@ -31,6 +31,7 @@ Description: =========
         
         
         .. _PySide: https://pypi.python.org/pypi/PySide
+        .. _PySide2: https://wiki.qt.io/PySide2
         .. _PyQt: http://www.riverbankcomputing.com/software/pyqt
         .. _pytest: http://pytest.org
         
@@ -80,16 +81,17 @@ Description: =========
         Requirements
         ============
         
-        Works with either PySide_ or PyQt_ (``PyQt5`` and ``PyQt4``) picking whichever
+        Works with either PySide_, PySide2_ or PyQt_ (``PyQt5`` and ``PyQt4``) picking whichever
         is available on the system, giving preference to the first one installed in
         this order:
         
+        - ``PySide2``
         - ``PyQt5``
         - ``PySide``
         - ``PyQt4``
         
         To force a particular API, set the configuration variable ``qt_api`` in your ``pytest.ini`` file to
-        ``pyqt5``, ``pyside``, ``pyqt4`` or ``pyqt4v2``. ``pyqt4v2`` sets the ``PyQt4``
+        ``pyqt5``, ``pyside``, ``pyside2``, ``pyqt4`` or ``pyqt4v2``. ``pyqt4v2`` sets the ``PyQt4``
         API to `version 2`_.
         
         .. code-block:: ini
@@ -163,6 +165,7 @@ Description: =========
         - Florian Bruhin (`@The-Compiler <https://github.com/The-Compiler>`_);
         - Guilherme Quentel Melo (`@gqmelo <https://github.com/gqmelo>`_);
         - Francesco Montesano (`@montefra <https://github.com/montefra>`_);
+        - Roman Yurchak (`@rth <https://github.com/rth>`_)
         
         **Powered by**
         
diff --git a/README.rst b/README.rst
index 1185a52..88b17a9 100644
--- a/README.rst
+++ b/README.rst
@@ -3,7 +3,7 @@ pytest-qt
 =========
 
 pytest-qt is a `pytest`_ plugin that allows programmers to write tests
-for `PySide`_ and `PyQt`_ applications.
+for `PySide`_, `PySide2` and `PyQt`_ applications.
 
 The main usage is to use the `qtbot` fixture, responsible for handling `qApp` 
 creation as needed and provides methods to simulate user interaction, 
@@ -23,6 +23,7 @@ like key presses and mouse clicks:
 
 
 .. _PySide: https://pypi.python.org/pypi/PySide
+.. _PySide2: https://wiki.qt.io/PySide2
 .. _PyQt: http://www.riverbankcomputing.com/software/pyqt
 .. _pytest: http://pytest.org
 
@@ -72,16 +73,17 @@ Features
 Requirements
 ============
 
-Works with either PySide_ or PyQt_ (``PyQt5`` and ``PyQt4``) picking whichever
+Works with either PySide_, PySide2_ or PyQt_ (``PyQt5`` and ``PyQt4``) picking whichever
 is available on the system, giving preference to the first one installed in
 this order:
 
+- ``PySide2``
 - ``PyQt5``
 - ``PySide``
 - ``PyQt4``
 
 To force a particular API, set the configuration variable ``qt_api`` in your ``pytest.ini`` file to
-``pyqt5``, ``pyside``, ``pyqt4`` or ``pyqt4v2``. ``pyqt4v2`` sets the ``PyQt4``
+``pyqt5``, ``pyside``, ``pyside2``, ``pyqt4`` or ``pyqt4v2``. ``pyqt4v2`` sets the ``PyQt4``
 API to `version 2`_.
 
 .. code-block:: ini
@@ -155,6 +157,7 @@ Many thanks to:
 - Florian Bruhin (`@The-Compiler <https://github.com/The-Compiler>`_);
 - Guilherme Quentel Melo (`@gqmelo <https://github.com/gqmelo>`_);
 - Francesco Montesano (`@montefra <https://github.com/montefra>`_);
+- Roman Yurchak (`@rth <https://github.com/rth>`_)
 
 **Powered by**
 
diff --git a/appveyor.yml b/appveyor.yml
index 400ae94..cd86073 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,27 +1,63 @@
-environment:
-  matrix:
-    - INSTALL_QT: "py34-pyqt5"
-      TESTENVS: "py34-pyqt5"
-
-    - INSTALL_QT: "py35-pyqt5"
-      TESTENVS: "py35-pyqt5"
-
-    - INSTALL_QT: "py34-pyqt4"
-      TESTENVS: "py34-pyqt4"
+# Adapted from the qtpy Appveyor setup
 
-    - INSTALL_QT: "py27-pyqt4"
-      TESTENVS: "py27-pyqt4"
+environment:
+  global:
+      PYTHON: "C:\\conda"
+      CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci-helpers\\appveyor\\windows_sdk.cmd"
+      PYTHON_ARCH: "64" # needs to be set for CMD_IN_ENV to succeed. If a mix
+                        # of 32 bit and 64 bit builds are needed, move this
+                        # to the matrix section.
+      # Used by atropy ci-helpers
+      CONDA_CHANNELS: "conda-forge"
 
-    - TESTENVS: "py27-pyside,py34-pyside,lint"
+  matrix:
+    - PYTHON_VERSION: "2.7"
+      PYTEST_QT_API: "pyqt4"
+      CONDA_DEPENDENCIES: "pytest pyqt=4.*"
+    - PYTHON_VERSION: "2.7"
+      PYTEST_QT_API: "pyqt4v2"
+      CONDA_DEPENDENCIES: "pytest pyqt=4.*"
+    - PYTHON_VERSION: "2.7"
+      PYTEST_QT_API: "pyside"
+      CONDA_DEPENDENCIES: "pytest pyside=1.*"
+      
+    - PYTHON_VERSION: "3.4"
+      PYTEST_QT_API: "pyqt4"
+      CONDA_DEPENDENCIES: "pytest pyqt=4.*"
+    - PYTHON_VERSION: "3.4"
+      PYTEST_QT_API: "pyqt4v2"
+      CONDA_DEPENDENCIES: "pytest pyqt=4.*"
+    - PYTHON_VERSION: "3.4"
+      PYTEST_QT_API: "pyside"
+      CONDA_DEPENDENCIES: "pytest pyside=1.*"
+    - PYTHON_VERSION: "3.4"
+      PYTEST_QT_API: "pyqt5"
+      CONDA_DEPENDENCIES: "pytest pyqt=5.*"
+    - PYTHON_VERSION: "3.5"
+      PYTEST_QT_API: "pyside2"
+      CONDA_DEPENDENCIES: "pytest pyside2=2.*"
+
+platform:
+    -x64
 
 install:
-  - C:\Python27\python -u scripts\install-qt.py
-  - C:\Python27\python -m pip install tox
-
-cache:
-  - C:\Installers -> appveyor.yml, scripts\install-qt.py
-
-build: false  # Not a C# project
+    # If there is a newer build queued for the same PR, cancel this one.
+    # The AppVeyor 'rollout builds' option is supposed to serve the same
+    # purpose but it is problematic because it tends to cancel builds pushed
+    # directly to master instead of just PR builds (or the converse).
+    # credits: JuliaLang developers.
+    - ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
+        https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
+        Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
+          throw "There are newer queued builds for this pull request, failing early." }
+    - "git clone --depth 1 git://github.com/astropy/ci-helpers.git"
+    - "powershell ci-helpers/appveyor/install-miniconda.ps1"
+    - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
+    - "activate test"
+    - "pip install -e ."
+
+# Not a .NET project, we build in the install step instead
+build: false
 
 test_script:
-  - C:\Python27\scripts\tox -e %TESTENVS%
+  - "%CMD_IN_ENV% python -m pytest -v tests/"
diff --git a/docs/intro.rst b/docs/intro.rst
index 597113b..28d6e39 100644
--- a/docs/intro.rst
+++ b/docs/intro.rst
@@ -30,16 +30,17 @@ Python 2.7 or later, including Python 3.4+.
 
 Requires pytest version 2.7 or later.
 
-Works with either ``PyQt5``, ``PySide`` or ``PyQt4``, picking whichever
+Works with either ``PyQt5``, ``PyQt4``, ``PySide`` or ``PySide2``, picking whichever
 is available on the system giving preference to the first one installed in
 this order:
 
+- ``PySide2``
 - ``PyQt5``
 - ``PySide``
 - ``PyQt4``
 
 To force a particular API, set the configuration variable ``qt_api`` in your ``pytest.ini`` file to
-``pyqt5``, ``pyside``, ``pyqt4`` or ``pyqt4v2``. ``pyqt4v2`` sets the ``PyQt4``
+``pyqt5``, ``pyside``, ``pyside2``, ``pyqt4`` or ``pyqt4v2``. ``pyqt4v2`` sets the ``PyQt4``
 API to `version 2`_.
 
 .. code-block:: ini
diff --git a/pytest_qt.egg-info/PKG-INFO b/pytest_qt.egg-info/PKG-INFO
index 01a6584..45ae18f 100644
--- a/pytest_qt.egg-info/PKG-INFO
+++ b/pytest_qt.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pytest-qt
-Version: 2.1.2
+Version: 2.2.0
 Summary: pytest support for PyQt and PySide applications
 Home-page: http://github.com/pytest-dev/pytest-qt
 Author: Bruno Oliveira
@@ -11,7 +11,7 @@ Description: =========
         =========
         
         pytest-qt is a `pytest`_ plugin that allows programmers to write tests
-        for `PySide`_ and `PyQt`_ applications.
+        for `PySide`_, `PySide2` and `PyQt`_ applications.
         
         The main usage is to use the `qtbot` fixture, responsible for handling `qApp` 
         creation as needed and provides methods to simulate user interaction, 
@@ -31,6 +31,7 @@ Description: =========
         
         
         .. _PySide: https://pypi.python.org/pypi/PySide
+        .. _PySide2: https://wiki.qt.io/PySide2
         .. _PyQt: http://www.riverbankcomputing.com/software/pyqt
         .. _pytest: http://pytest.org
         
@@ -80,16 +81,17 @@ Description: =========
         Requirements
         ============
         
-        Works with either PySide_ or PyQt_ (``PyQt5`` and ``PyQt4``) picking whichever
+        Works with either PySide_, PySide2_ or PyQt_ (``PyQt5`` and ``PyQt4``) picking whichever
         is available on the system, giving preference to the first one installed in
         this order:
         
+        - ``PySide2``
         - ``PyQt5``
         - ``PySide``
         - ``PyQt4``
         
         To force a particular API, set the configuration variable ``qt_api`` in your ``pytest.ini`` file to
-        ``pyqt5``, ``pyside``, ``pyqt4`` or ``pyqt4v2``. ``pyqt4v2`` sets the ``PyQt4``
+        ``pyqt5``, ``pyside``, ``pyside2``, ``pyqt4`` or ``pyqt4v2``. ``pyqt4v2`` sets the ``PyQt4``
         API to `version 2`_.
         
         .. code-block:: ini
@@ -163,6 +165,7 @@ Description: =========
         - Florian Bruhin (`@The-Compiler <https://github.com/The-Compiler>`_);
         - Guilherme Quentel Melo (`@gqmelo <https://github.com/gqmelo>`_);
         - Francesco Montesano (`@montefra <https://github.com/montefra>`_);
+        - Roman Yurchak (`@rth <https://github.com/rth>`_)
         
         **Powered by**
         
diff --git a/pytest_qt.egg-info/SOURCES.txt b/pytest_qt.egg-info/SOURCES.txt
index 0b39955..89ff8db 100644
--- a/pytest_qt.egg-info/SOURCES.txt
+++ b/pytest_qt.egg-info/SOURCES.txt
@@ -43,7 +43,6 @@ pytestqt/plugin.py
 pytestqt/qt_compat.py
 pytestqt/qtbot.py
 pytestqt/wait_signal.py
-scripts/install-qt.py
 scripts/link_pyqt.py
 tests/conftest.py
 tests/test_basics.py
diff --git a/pytestqt/_version.py b/pytestqt/_version.py
index cde4617..bd2332f 100644
--- a/pytestqt/_version.py
+++ b/pytestqt/_version.py
@@ -1,4 +1,4 @@
 # coding: utf-8
 # file generated by setuptools_scm
 # don't change, don't track in version control
-version = '2.1.2'
+version = '2.2.0'
diff --git a/pytestqt/qt_compat.py b/pytestqt/qt_compat.py
index 796ebaa..0cc003e 100644
--- a/pytestqt/qt_compat.py
+++ b/pytestqt/qt_compat.py
@@ -1,6 +1,6 @@
 """
 Provide a common way to import Qt classes used by pytest-qt in a unique manner,
-abstracting API differences between PyQt4, PyQt5 and PySide.
+abstracting API differences between PyQt4, PyQt5, PySide and PySide2.
 
 .. note:: This module is not part of pytest-qt public API, hence its interface
 may change between releases and users should not rely on it.
@@ -8,8 +8,7 @@ may change between releases and users should not rely on it.
 Based on from https://github.com/epage/PythonUtils.
 """
 
-from __future__ import with_statement
-from __future__ import division
+from __future__ import with_statement, division
 from collections import namedtuple
 import os
 
@@ -29,7 +28,7 @@ class _QtApi:
         api = os.environ.get('PYTEST_QT_API')
         if api is not None:
             api = api.lower()
-            if api not in ('pyside', 'pyqt4', 'pyqt4v2', 'pyqt5'):  # pragma: no cover
+            if api not in ('pyside', 'pyside2', 'pyqt4', 'pyqt4v2', 'pyqt5'):  # pragma: no cover
                 msg = 'Invalid value for $PYTEST_QT_API: %s'
                 raise RuntimeError(msg % api)
         return api
@@ -42,22 +41,27 @@ class _QtApi:
             except ImportError:
                 return False
 
-        if _can_import('PyQt5'):
+        # Note, not importing only the root namespace because when uninstalling from conda,
+        # the namespace can still be there.
+        if _can_import('PySide2.QtCore'):
+            return 'pyside2'
+        elif _can_import('PyQt5.QtCore'):
             return 'pyqt5'
-        elif _can_import('PySide'):
+        elif _can_import('PySide.QtCore'):
             return 'pyside'
-        elif _can_import('PyQt4'):
+        elif _can_import('PyQt4.QtCore'):
             return 'pyqt4'
         return None
 
     def set_qt_api(self, api):
         self.pytest_qt_api = api or self._get_qt_api_from_env() or self._guess_qt_api()
         if not self.pytest_qt_api:  # pragma: no cover
-            msg = 'pytest-qt requires either PySide, PyQt4 or PyQt5 to be installed'
+            msg = 'pytest-qt requires either PySide, PySide2, PyQt4 or PyQt5 to be installed'
             raise RuntimeError(msg)
 
         _root_modules = {
             'pyside': 'PySide',
+            'pyside2': 'PySide2',
             'pyqt4': 'PyQt4',
             'pyqt4v2': 'PyQt4',
             'pyqt5': 'PyQt5',
@@ -100,21 +104,33 @@ class _QtApi:
         self.qInstallMsgHandler = None
         self.qInstallMessageHandler = None
 
-        if self.pytest_qt_api == 'pyside':
+        if self.pytest_qt_api.startswith('pyside'):
             self.Signal = QtCore.Signal
             self.Slot = QtCore.Slot
             self.Property = QtCore.Property
-            self.QApplication = QtGui.QApplication
-            self.QWidget = QtGui.QWidget
             self.QStringListModel = QtGui.QStringListModel
-            self.qInstallMsgHandler = QtCore.qInstallMsgHandler
 
             self.QStandardItem = QtGui.QStandardItem
             self.QStandardItemModel = QtGui.QStandardItemModel
-            self.QStringListModel = QtGui.QStringListModel
-            self.QSortFilterProxyModel = QtGui.QSortFilterProxyModel
             self.QAbstractListModel = QtCore.QAbstractListModel
             self.QAbstractTableModel = QtCore.QAbstractTableModel
+            self.QStringListModel = QtGui.QStringListModel
+
+            if self.pytest_qt_api == 'pyside2':
+                _QtWidgets = _import_module('QtWidgets')
+                self.QApplication = _QtWidgets.QApplication
+                self.QWidget = _QtWidgets.QWidget
+                self.QLineEdit = _QtWidgets.QLineEdit
+                self.qInstallMessageHandler = QtCore.qInstallMessageHandler
+
+                self.QSortFilterProxyModel = QtCore.QSortFilterProxyModel
+            else:
+                self.QApplication = QtGui.QApplication
+                self.QWidget = QtGui.QWidget
+                self.QLineEdit = QtGui.QLineEdit
+                self.qInstallMsgHandler = QtCore.qInstallMsgHandler
+
+                self.QSortFilterProxyModel = QtGui.QSortFilterProxyModel
 
             def extract_from_variant(variant):
                 """PySide does not expose QVariant API"""
@@ -180,9 +196,16 @@ class _QtApi:
             self.make_variant = make_variant
 
     def get_versions(self):
-        if self.pytest_qt_api == 'pyside':
-            import PySide
-            return VersionTuple('PySide', PySide.__version__, self.QtCore.qVersion(),
+        if self.pytest_qt_api in ('pyside', 'pyside2'):
+            qt_api_name = 'PySide2' if self.pytest_qt_api == 'pyside2' else 'PySide'
+            if self.pytest_qt_api == 'pyside2':
+                import PySide2
+                version = PySide2.__version__
+            else:
+                import PySide
+                version = PySide.__version__
+
+            return VersionTuple(qt_api_name, version, self.QtCore.qVersion(),
                                 self.QtCore.__version__)
         else:
             qt_api_name = 'PyQt5' if self.pytest_qt_api == 'pyqt5' else 'PyQt4'
diff --git a/pytestqt/qtbot.py b/pytestqt/qtbot.py
index 67e8ae6..7333f93 100644
--- a/pytestqt/qtbot.py
+++ b/pytestqt/qtbot.py
@@ -218,7 +218,7 @@ class QtBot(object):
 
         .. note:: This method is also available as ``wait_for_window_shown`` (pep-8 alias)
         """
-        if qt_api.pytest_qt_api == 'pyqt5':
+        if hasattr(qt_api.QtTest.QTest, 'qWaitForWindowExposed'):
             return qt_api.QtTest.QTest.qWaitForWindowExposed(widget)
         else:
             return qt_api.QtTest.QTest.qWaitForWindowShown(widget)
diff --git a/scripts/install-qt.py b/scripts/install-qt.py
deleted file mode 100644
index 2ad4f68..0000000
--- a/scripts/install-qt.py
+++ /dev/null
@@ -1,88 +0,0 @@
-"""
-Simple script to install PyQt or PySide in CI (Travis and AppVeyor).
-"""
-from __future__ import print_function
-import os
-import sys
-import subprocess
-import urllib
-
-
-if 'APPVEYOR' in os.environ:
-    def fix_registry(python_ver):
-        """Update install path on windows registry so PyQt installation installs at the correct
-        location.
-        python_ver must be "34", "27", etc.
-        """
-        import _winreg as winreg
-        python_dir = r'C:\Python%s' % python_ver
-        print("Fixing registry %s..." % python_ver)
-        assert os.path.isdir(python_dir)
-        registry_key = r'Software\Python\PythonCore\%s.%s' % (python_ver[0], python_ver[1])
-        with winreg.OpenKey(winreg.HKEY_CURRENT_USER,
-                            registry_key, 0,
-                            winreg.KEY_WRITE) as key:
-            winreg.SetValue(key, 'InstallPath', winreg.REG_SZ, python_dir)
-
-    base_url = 'http://downloads.sourceforge.net/project/pyqt/'
-    downloads = {
-        'py34-pyqt5': 'PyQt5/PyQt-5.5/PyQt5-5.5-gpl-Py3.4-Qt5.5.0-x32.exe',
-        'py35-pyqt5': 'PyQt5/PyQt-5.6/PyQt5-5.6-gpl-Py3.5-Qt5.6.0-x32-2.exe',
-        'py34-pyqt4': 'PyQt4/PyQt-4.11.4/PyQt4-4.11.4-gpl-Py3.4-Qt4.8.7-x32.exe',
-        'py27-pyqt4': 'PyQt4/PyQt-4.11.4/PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x32.exe',
-    }
-    if 'INSTALL_QT' in os.environ:
-        fix_registry('35')
-        caption = os.environ['INSTALL_QT']
-        installers_dir = r'C:\Installers'
-        if not os.path.isdir(installers_dir):
-            os.makedirs(installers_dir)
-        installer = os.path.join(installers_dir, 'install-%s.exe' % caption)
-        if not os.path.isfile(installer):
-            # download all files because the cache is for all builds
-            for cap, url in sorted(downloads.items()):
-                print("Downloading %s..." % cap)
-                filename = os.path.join(installers_dir, 'install-%s.exe' % cap)
-                urllib.urlretrieve(base_url + url, filename)
-        else:
-            print('Using cached installers')
-        print('Installing %s...' % caption)
-        subprocess.check_call([installer, '/S'])
-        python = caption.split('-')[0]
-        assert python[:2] == 'py'
-        executable = r'C:\Python%s\python.exe' % python[2:]
-        url = downloads[caption]
-        module = url.split('/')[0]
-        cmdline = [executable, '-c', 'import %s;print(%s)' % (module, module)]
-        print('Checking: %r' % cmdline)
-        subprocess.check_call(cmdline)
-        print('OK')
-    else:
-        print('Skip install for this build')
-
-elif 'TRAVIS' in os.environ:
-    def apt_get_install(packages):
-        print('Installing %s...' % ', '.join(packages))
-        subprocess.check_call(['sudo', 'apt-get', 'install', '-y', '-qq'] + packages)
-
-    py3k = sys.version_info[0] == 3
-    pyqt_version = {'pyqt4': 4,
-                    'pyqt4v2': 4,
-                    'pyqt5': 5,
-                    }
-    if os.environ['PYTEST_QT_API'] in pyqt_version:
-        pyqt_ver = pyqt_version[os.environ['PYTEST_QT_API']]
-        if py3k:
-            pkg = 'python3-pyqt%s' % pyqt_ver
-        else:
-            pkg = 'python-qt%s' % pyqt_ver
-        apt_get_install([pkg])
-    else:
-        if py3k:
-            pkg = 'python3-pyside'
-        else:
-            pkg = 'python-pyside'
-        apt_get_install([pkg])
-
-else:
-    print('Nothing to do (not in Travis or AppVeyor)')
diff --git a/tests/test_basics.py b/tests/test_basics.py
index fddac5c..e0af561 100644
--- a/tests/test_basics.py
+++ b/tests/test_basics.py
@@ -324,7 +324,7 @@ def test_parse_ini_boolean_invalid():
         pytestqt.qtbot._parse_ini_boolean('foo')
 
 
- at pytest.mark.parametrize('option_api', ['pyqt4', 'pyqt5', 'pyside'])
+ at pytest.mark.parametrize('option_api', ['pyqt4', 'pyqt5', 'pyside', 'pyside2'])
 def test_qt_api_ini_config(testdir, option_api):
     """
     Test qt_api ini option handling.
@@ -344,7 +344,7 @@ def test_qt_api_ini_config(testdir, option_api):
     ''')
 
     result = testdir.runpytest_subprocess()
-    if qt_api.pytest_qt_api.startswith(option_api):  # handle pyqt4v2
+    if qt_api.pytest_qt_api.replace('v2', '') == option_api:  # handle pyqt4v2
         result.stdout.fnmatch_lines([
             '* 1 passed in *'
         ])
diff --git a/tests/test_logging.py b/tests/test_logging.py
index 2f528e5..dfd97e2 100644
--- a/tests/test_logging.py
+++ b/tests/test_logging.py
@@ -4,6 +4,8 @@ import pytest
 
 from pytestqt.qt_compat import qt_api
 
+pytestmark = pytest.mark.skipif(qt_api.pytest_qt_api == 'pyside2', reason="https://bugreports.qt.io/browse/PYSIDE-435")
+
 
 @pytest.mark.parametrize('test_succeeds', [True, False])
 @pytest.mark.parametrize('qt_log', [True, False])
diff --git a/tests/test_qtest_proxies.py b/tests/test_qtest_proxies.py
index 3f53149..715f20f 100644
--- a/tests/test_qtest_proxies.py
+++ b/tests/test_qtest_proxies.py
@@ -4,7 +4,7 @@ import pytest
 from pytestqt.qt_compat import qt_api
 
 
-fails_on_pyqt = pytest.mark.xfail('qt_api.pytest_qt_api != "pyside"')
+fails_on_pyqt = pytest.mark.xfail('not qt_api.pytest_qt_api.startswith("pyside")')
 
 
 @pytest.mark.parametrize('expected_method', [
@@ -29,4 +29,4 @@ def test_expected_qtest_proxies(qtbot, expected_method):
     Ensure that we are exporting expected QTest API methods.
     """
     assert hasattr(qtbot, expected_method)
-    assert getattr(qtbot, expected_method).__name__ == expected_method
\ No newline at end of file
+    assert getattr(qtbot, expected_method).__name__ == expected_method
diff --git a/tests/test_wait_signal.py b/tests/test_wait_signal.py
index c0a6960..7cde471 100644
--- a/tests/test_wait_signal.py
+++ b/tests/test_wait_signal.py
@@ -293,8 +293,8 @@ def test_destroyed(qtbot):
 
     For some reason, this crashes PySide although it seems perfectly fine code.
     """
-    if qt_api.pytest_qt_api == 'pyside':
-        pytest.skip('test crashes PySide')
+    if qt_api.pytest_qt_api.startswith('pyside'):
+        pytest.skip('test crashes PySide and PySide2')
 
     import sip
 
@@ -708,7 +708,7 @@ def get_mixed_signals_with_guaranteed_name(signaller):
     Returns a list of signals with the guarantee that the signals have names (i.e. the names are
     manually provided in case of using PySide, where the signal names cannot be determined at run-time).
     """
-    if qt_api.pytest_qt_api == 'pyside':
+    if qt_api.pytest_qt_api.startswith('pyside'):
         signals = [(signaller.signal, "signal()"), (signaller.signal_args, "signal_args(QString,int)"),
                    (signaller.signal_args, "signal_args(QString,int)")]
     else:
@@ -790,7 +790,7 @@ class TestWaitSignalTimeoutErrorMessage:
         In a situation where a signal without args is expected but not emitted, tests that the TimeoutError
         message contains the name of the signal (without arguments).
         """
-        if qt_api.pytest_qt_api == 'pyside':
+        if qt_api.pytest_qt_api.startswith('pyside'):
             signal = (signaller.signal, "signal()")
         else:
             signal = signaller.signal
@@ -811,7 +811,7 @@ class TestWaitSignalTimeoutErrorMessage:
         if sys.version_info >= (3,5):
             pytest.skip("Only on Python 3.4 and lower double-wrapped functools.partial callbacks are a problem")
 
-        if qt_api.pytest_qt_api == 'pyside':
+        if qt_api.pytest_qt_api.startswith('pyside'):
             signal = (signaller.signal_single_arg, "signal_single_arg(int)")
         else:
             signal = signaller.signal_single_arg
@@ -836,7 +836,7 @@ class TestWaitSignalTimeoutErrorMessage:
         rejected by a callback, tests that the TimeoutError message contains the name of the signal and the
         list of non-accepted arguments.
         """
-        if qt_api.pytest_qt_api == 'pyside':
+        if qt_api.pytest_qt_api.startswith('pyside'):
             signal = (signaller.signal_single_arg, "signal_single_arg(int)")
         else:
             signal = signaller.signal_single_arg
@@ -858,7 +858,7 @@ class TestWaitSignalTimeoutErrorMessage:
         rejected by a callback, tests that the TimeoutError message contains the name of the signal and the
         list of tuples of the non-accepted arguments.
         """
-        if qt_api.pytest_qt_api == 'pyside':
+        if qt_api.pytest_qt_api.startswith('pyside'):
             signal = (signaller.signal_args, "signal_args(QString,int)")
         else:
             signal = signaller.signal_args
@@ -999,7 +999,7 @@ class TestWaitSignalsTimeoutErrorMessage:
         by the user. This degenerate messages doesn't contain the signals' names, and includes a hint to the user how
         to fix the situation.
         """
-        if qt_api.pytest_qt_api != 'pyside':
+        if not qt_api.pytest_qt_api.startswith('pyside'):
             pytest.skip("test only makes sense for PySide, whose signals don't contain a name!")
 
         with pytest.raises(TimeoutError) as excinfo:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/pytest-qt.git



More information about the Python-modules-commits mailing list