question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Integration with qtpy

See original GitHub issue

The support of multiple PyQt / PySide backends is a recurrent problem for any project working with Qt in Python. In pytest-qt it is solved by providing a compatibility _QtApi interface in qt_compat.py (that is not in the public interface). At the same time there are packages that specialize in providing such a compatibility interface, namely spyder-ide/qtpy and mottosso/Qt.py. For project that use one of those packages (e.g. matplotlib is considering it), and wanting to test it with with pytest-qt it would mean that they would not, technically be testing the project in the same conditions (and it would also mean setting differently named environment variables twice PYTEST_QT_API and QT_API or QT_PREFERRED_BINDING.)

I think the integration could be straightforward: e.g. to integrate with qtpy, the following should almost work,

At the end of pytestqt/qt_compat.py

try:
    if 'QT_API' not in os.environ and 'PYTEST_QT_API' in os.environ:
        os.environ['QT_API'] = os.environ['PYTEST_QT_API']
    import qtpy
    qt_api = qtpy
    qt_api.pytest_qt_api = qtpy.API
except ImportError:
     # fallback to the built-in compatibility layer..
    qt_api = _QtApi()

And maybe one extra environment in TravisCI for testing…

What do you think?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
The-Compilercommented, Sep 15, 2017

There’s already some discussion about this at https://github.com/pytest-dev/pytest-qt/pull/130#issuecomment-219218794 FWIW.

0reactions
nicoddemuscommented, Jun 21, 2018

Thanks for the pointer @machinekoder.

But as commented in https://github.com/pytest-dev/pytest-qt/pull/130#issuecomment-219218794 it is probably not worth to use a wrapper, the qt_compat module provides lazy loading and doesn’t really add too much to maintenance because we don’t need to import the entire API anyway, just a few symbols.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python-QML integration
This tutorial provides a quick walk-through of a python application that loads, and interacts with a QML file. QML is a declarative language...
Read more >
PyQt integration with Sqlalchemy - python
Can anyone help with a code snippet that can add information through a form created into database using Sqlalchemy? from PyQt4 import QtCore, ......
Read more >
GUI integration with Qt — Fluendo SDK documentation
Compile and link a simple Qt application against the Fluendo SDK. Render the video frames on a native window of your choice. Open,...
Read more >
Qt Ogre3D integration now available in master | OGRE
While there have been snippets to provide Ogre integration with Qt for a long time, there is now an officially provided version in...
Read more >
Gnome integration for Qt based applications in Flatpak
Gnome integration for Qt based applications in Flatpak ... Currently wherever you start a Qt application, it would always look like a KDE ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found