Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ before_script:
- sleep 1

script:
- sudo catchsegv coverage run --source=pytestqt setup.py test
- catchsegv coverage run --source=pytestqt -m pytest tests
- sudo tox -e lint
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't really get rid of this call to tox using sudo:

Obtaining file:///home/travis/build/nicoddemus/pytest-qt
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "/home/travis/build/nicoddemus/pytest-qt/.tox/lint/lib/python3.4/site-packages/setuptools/dist.py", line 418, in fetch_build_egg
        cmd = self._egg_fetcher
    AttributeError: 'Distribution' object has no attribute '_egg_fetcher'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/travis/build/nicoddemus/pytest-qt/.tox/lint/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 462, in check_site_dir
        open(testfile, 'w').close()
    PermissionError: [Errno 13] Permission denied: './.eggs/test-easy-install-5916.write-test'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/travis/build/nicoddemus/pytest-qt/setup.py", line 61, in <module>
        cmdclass={'test': PyTest},
      File "/opt/python/3.4.6/lib/python3.4/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "/home/travis/build/nicoddemus/pytest-qt/.tox/lint/lib/python3.4/site-packages/setuptools/dist.py", line 320, in __init__
        self.fetch_build_eggs(attrs['setup_requires'])
      File "/home/travis/build/nicoddemus/pytest-qt/.tox/lint/lib/python3.4/site-packages/setuptools/dist.py", line 377, in fetch_build_eggs
        replace_conflicting=True,
      File "/home/travis/build/nicoddemus/pytest-qt/.tox/lint/lib/python3.4/site-packages/pkg_resources/__init__.py", line 852, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "/home/travis/build/nicoddemus/pytest-qt/.tox/lint/lib/python3.4/site-packages/pkg_resources/__init__.py", line 1124, in best_match
        return self.obtain(req, installer)
      File "/home/travis/build/nicoddemus/pytest-qt/.tox/lint/lib/python3.4/site-packages/pkg_resources/__init__.py", line 1136, in obtain
        return installer(requirement)
      File "/home/travis/build/nicoddemus/pytest-qt/.tox/lint/lib/python3.4/site-packages/setuptools/dist.py", line 443, in fetch_build_egg
        cmd.ensure_finalized()
      File "/opt/python/3.4.6/lib/python3.4/distutils/cmd.py", line 107, in ensure_finalized
        self.finalize_options()
      File "/home/travis/build/nicoddemus/pytest-qt/.tox/lint/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 320, in finalize_options
        self.check_site_dir()
      File "/home/travis/build/nicoddemus/pytest-qt/.tox/lint/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 465, in check_site_dir
        self.cant_write_to_target()
      File "/home/travis/build/nicoddemus/pytest-qt/.tox/lint/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 528, in cant_write_to_target
        raise DistutilsError(msg)
    distutils.errors.DistutilsError: can't create or remove files in install directory
    
    The following error occurred while trying to add or remove files in the
    installation directory:
    
        [Errno 13] Permission denied: './.eggs/test-easy-install-5916.write-test'
    
    The installation directory you specified (via --install-dir, --prefix, or
    the distutils default setting) was:
    
        ./.eggs
    
    Perhaps your account does not have write access to this directory?  If the
    installation directory is a system-owned directory, you may need to sign in
    as the administrator or "root" account.  If you do not have administrative
    access to this machine, you may wish to choose a different installation
    directory, preferably one that is listed in your PYTHONPATH environment
    variable.
    
    For information on other options, you may wish to consult the
    documentation at:
    
      https://setuptools.readthedocs.io/en/latest/easy_install.html
    
    Please make the appropriate changes for your system and try again.
    
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /home/travis/build/nicoddemus/pytest-qt/

- sudo chmod -R a+rw .

after_success:
- coveralls
Expand Down
145 changes: 75 additions & 70 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2.1.2
-----

- Fix issue where ``pytestqt`` was hiding the information when there's an exception raised from another exception on Python 3.

2.1.1
-----

Expand Down Expand Up @@ -64,7 +69,7 @@ New Features
for ModelTester (`#63`_).

* New ``qtbot.waitUntil`` method, which continuously calls a callback until a condition
is met or a timeout is reached. Useful for testing asynchronous features
is met or a timeout is reached. Useful for testing asynchronous features
(like in X window environments for example).

* ``waitSignal`` and ``waitSignals`` can receive an optional callback (or list of callbacks)
Expand Down Expand Up @@ -152,10 +157,10 @@ Other Changes
- ``qtbot`` now has a new ``wait`` method which does a blocking wait while the
event loop continues to run, similar to ``QTest::qWait``. Thanks
`@The-Compiler`_ for the PR (closes `107`_)!

- raise ``RuntimeError`` instead of ``ImportError`` when failing to import
any Qt binding: raising the latter causes `pluggy` in `pytest-2.8` to
generate a subtle warning instead of a full blown error.
any Qt binding: raising the latter causes `pluggy` in `pytest-2.8` to
generate a subtle warning instead of a full blown error.
Thanks `@Sheeo`_ for bringing this problem to attention (closes `109`_).

.. _105: https://github.com/pytest-dev/pytest-qt/issues/105
Expand All @@ -167,148 +172,148 @@ Other Changes
1.8.0
-----

- ``pytest.mark.qt_log_ignore`` now supports an ``extend`` parameter that will extend
the list of regexes used to ignore Qt messages (defaults to False).
- ``pytest.mark.qt_log_ignore`` now supports an ``extend`` parameter that will extend
the list of regexes used to ignore Qt messages (defaults to False).
Thanks `@The-Compiler`_ for the PR (`99`_).

- Fixed internal error when interacting with other plugins that raise an error,
hiding the original exception (`98`_). Thanks `@The-Compiler`_ for the PR!

- Now ``pytest-qt`` is properly tested with PyQt5 on Travis-CI. Many thanks
to `@The-Compiler`_ for the PR!

.. _99: https://github.com/pytest-dev/pytest-qt/issues/99
.. _98: https://github.com/pytest-dev/pytest-qt/issues/98

1.7.0
-----

- ``PYTEST_QT_API`` can now be set to ``pyqt4v2`` in order to use version 2 of the
- ``PYTEST_QT_API`` can now be set to ``pyqt4v2`` in order to use version 2 of the
PyQt4 API. Thanks `@montefra`_ for the PR (`93`_)!
.. _93: https://github.com/pytest-dev/pytest-qt/issues/93

.. _93: https://github.com/pytest-dev/pytest-qt/issues/93


1.6.0
-----

- Reduced verbosity when exceptions are captured in virtual methods
(`77`_, thanks `@The-Compiler`_).

- ``pytestqt.plugin`` has been split in several files (`74`_) and tests have been
moved out of the ``pytestqt`` package. This should not affect users, but it
is worth mentioning nonetheless.

- ``QApplication.processEvents()`` is now called before and after other fixtures
and teardown hooks, to better try to avoid non-processed events from leaking
from one test to the next. (67_, thanks `@The-Compiler`_).
and teardown hooks, to better try to avoid non-processed events from leaking
from one test to the next. (67_, thanks `@The-Compiler`_).

- Show Qt/PyQt/PySide versions in pytest header (68_, thanks `@The-Compiler`_!).

- Disconnect SignalBlocker functions after its loop exits to ensure second
emissions that call the internal functions on the now-garbage-collected
emissions that call the internal functions on the now-garbage-collected
SignalBlocker instance (#69, thanks `@The-Compiler`_ for the PR).
.. _77: https://github.com/pytest-dev/pytest-qt/issues/77

.. _77: https://github.com/pytest-dev/pytest-qt/issues/77
.. _74: https://github.com/pytest-dev/pytest-qt/issues/74
.. _67: https://github.com/pytest-dev/pytest-qt/issues/67
.. _68: https://github.com/pytest-dev/pytest-qt/issues/68

1.5.1
-----

- 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 <http://pyqt.sourceforge.net/Docs/PyQt5/incompatibilities.html#pyqt-v5-5>`_
to call ``abort`` by default, which will crash the interpreter.
- 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 <http://pyqt.sourceforge.net/Docs/PyQt5/incompatibilities.html#pyqt-v5-5>`_
to call ``abort`` by default, which will crash the interpreter.
(65_, thanks `@The-Compiler`_).
.. _65: https://github.com/pytest-dev/pytest-qt/issues/65

.. _65: https://github.com/pytest-dev/pytest-qt/issues/65

1.5.0
-----

- Fixed log line number in messages, and provide better contextual information
- 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

- 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``.

- 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_).
- New ``qtlog`` now sports a context manager method, ``disabled`` (58_).
Thanks `@The-Compiler`_ for the idea and testing;

.. _55: https://github.com/pytest-dev/pytest-qt/issues/55
.. _58: https://github.com/pytest-dev/pytest-qt/issues/58
.. _59: https://github.com/pytest-dev/pytest-qt/issues/59

1.4.0
-----

- 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.
- New method ``waitSignals``: will block untill **all** signals given are
- 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.

- New method ``waitSignals``: will block untill **all** signals given are
triggered (thanks `@The-Compiler`_ for idea and complete PR).
- New parameter ``raising`` to ``waitSignals`` and ``waitSignals``: when ``True``
will raise a ``qtbot.SignalTimeoutError`` exception when
timeout is reached (defaults to ``False``).

- New parameter ``raising`` to ``waitSignals`` and ``waitSignals``: when ``True``
will raise a ``qtbot.SignalTimeoutError`` exception when
timeout is reached (defaults to ``False``).
(thanks again to `@The-Compiler`_ for idea and complete PR).

- ``pytest-qt`` now requires ``pytest`` version >= 2.7.

.. _pytest-catchlog: https://pypi.python.org/pypi/pytest-catchlog

Internal changes to improve memory management
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- ``QApplication.exit()`` is no longer called at the end of the test session
- ``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

- ``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

- ``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

- ``QApplication.processEvents()`` is called at the end of each test to
make sure widgets are cleaned up;

1.3.0
-----

- 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
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!
.. _PyQt5: http://pyqt.sourceforge.net/Docs/PyQt5/introduction.html

.. _PyQt5: http://pyqt.sourceforge.net/Docs/PyQt5/introduction.html

1.2.3
-----

- 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
- 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.

1.2.2
-----

- Now it is possible to disable automatic exception capture by using markers or
a ``pytest.ini`` option. Consult the documentation for more information.
- 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

- ``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`_)
Expand All @@ -320,29 +325,29 @@ Internal changes to improve memory management
1.2.1
-----

- Fixed 16_: a signal emitted immediately inside a ``waitSignal`` block now
- Fixed 16_: a signal emitted immediately inside a ``waitSignal`` block now
works as expected (thanks `@baudren`_).

.. _16: https://github.com/pytest-dev/pytest-qt/issues/16

1.2.0
-----

This version include the new ``waitSignal`` function, which makes it easy
to write tests for long running computations that happen in other threads
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:

.. code-block:: python

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)

Expand All @@ -356,8 +361,8 @@ Many thanks to `@jdreaver`_ for discussion and complete PR! (`12`_, `13`_)

- Added ``stop`` as an alias for ``stopForInteraction`` (`10`_, thanks `@itghisi`_)

- Now exceptions raised in virtual methods make tests fail, instead of silently
passing (`11`_). If an exception is raised, the test will fail and it exceptions
- Now exceptions raised in virtual methods make tests fail, instead of silently
passing (`11`_). If an exception is raised, the test will fail and it exceptions
that happened inside virtual calls will be printed as such::


Expand All @@ -376,7 +381,7 @@ Many thanks to `@jdreaver`_ for discussion and complete PR! (`12`_, `13`_)

Thanks to `@jdreaver`_ for request and sample code!

- Fixed documentation for ``QtBot``: it was not being rendered in the
- Fixed documentation for ``QtBot``: it was not being rendered in the
docs due to an import error.

.. _10: https://github.com/pytest-dev/pytest-qt/issues/10
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ passenv=DISPLAY XAUTHORITY USER USERNAME

[testenv:lint]
basepython=python3.4
usedevelop=true
deps=
pytest
sphinx
Expand Down