Skip to content

Releases: pytest-dev/pytest-qt

4.4.0

07 Feb 21:22
Compare
Choose a tag to compare
Release 4.4.0

Simplify the pytest requirement because due to our own python requirement (3.8+), the pytest requirement is met.

4.3.1

22 Dec 21:02
Compare
Choose a tag to compare
Use an environment for deploy

Capturing exceptions during test tear down

01 Aug 19:07
Compare
Choose a tag to compare

Exceptions are now captured also during test tear down, as delayed events will get processed then and might raise exceptions in virtual methods; this is specially problematic in PyQt5.5, which changed the behavior to call abort by default, which will crash the interpreter. (#65, thanks @The-Compiler).

qtlog.disabled() and some bug fixes

29 Jun 21:08
Compare
Choose a tag to compare
  • Fixed log line number in messages, and provide better contextual information in Qt5 (#55, thanks @The-Compiler);
  • Fixed issue where exceptions inside a waitSignals or waitSignal with-statement block would be swallowed and a SignalTimeoutError would be raised instead. (#59, thanks @The-Compiler for bringing up the issue and providing a test case);
  • Fixed issue where the first usage of qapp fixture would return None. Thanks to @gqmelo for noticing and providing a PR;
  • New qtlog now sports a context manager method, disabled (#58). Thanks @The-Compiler for the idea and testing;

Qt Logging, waitSignals

06 Jun 22:35
Compare
Choose a tag to compare
  • Messages sent by qDebug, qWarning, qCritical are captured and displayed when tests fail, similar to pytest-catchlog. Also, tests can be configured to automatically fail if an unexpected message is generated. (See docs).
  • New method waitSignals: will block untill all signals given are triggered, see docs (thanks @The-Compiler for idea and complete PR).
  • New parameter raising to waitSignals and waitSignals: when True (defaults to False) will raise a qtbot.SignalTimeoutError exception when timeout is reached, see docs (thanks again to @The-Compiler for idea and complete PR).
  • pytest-qt now requires pytest version >= 2.7.

Internal changes to improve memory management

  • QApplication.exit() is no longer called at the end of the test session and the QApplication instance is not garbage collected anymore;
  • QtBot no longer receives a QApplication as a parameter in the constructor, always referencing QApplication.instance() now; this avoids keeping an extra reference in the qtbot instances.
  • deleteLater is called on widgets added in QtBot.addWidget at the end of each test;
  • QApplication.processEvents() is called at the end of each test to make sure widgets are cleaned up;

PyQt5 support

03 Apr 20:55
Compare
Choose a tag to compare

pytest-qt now supports PyQt5!

Which Qt api will be used is still detected automatically, but you can choose one using the PYTEST_QT_API environment variable (the old PYTEST_QT_FORCE_PYQT is still supported for backward compatibility).

Many thanks to @jdreaver for helping to test this release!

PyQt: no longer setting API version

14 Jan 20:05
Compare
Choose a tag to compare

Now the module qt_compat no longer sets QString and QVariant apis to 2 for PyQt, making it compatible for those still using version 1 of the API.

Small improvements

06 Nov 01:27
Compare
Choose a tag to compare
  • Now it is possible to disable automatic exception capture by using markers or a pytest.ini option. Consult the documentation for more information. (#26, thanks @datalyze-solutions for bringing this up)
  • QApplication instance is created only if it wasn't created yet (#21, thanks @fabioz!)
  • addWidget now keeps a weak reference its widgets (#20, thanks @fabioz)

Bug fix

10 Sep 22:52
Compare
Choose a tag to compare
  • Fixed #16: a signal emitted immediately inside a waitSignal block now works as expected (thanks @baudren)

waitSignal support added

03 Jul 00:53
Compare
Choose a tag to compare

This version include the new waitSignal function, which makes it easy to write tests for long running computations that happen in other threads or processes:

    def test_long_computation(qtbot):
        app = Application()

        # Watch for the app.worker.finished signal, then start the worker.
        with qtbot.waitSignal(app.worker.finished, timeout=10000) as blocker:
            blocker.connect(app.worker.failed)  # Can add other signals to blocker
            app.worker.start()
            # Test will wait here until either signal is emitted, or 10 seconds has elapsed

        assert blocker.signal_triggered  # Assuming the work took less than 10 seconds
        assert_application_results(app)

Many thanks to @jdreaver for discussion and complete PR! (#12, #13)