|
| 1 | +========= |
| 2 | +pytest-qt |
| 3 | +========= |
| 4 | + |
| 5 | +pytest-qt is a `pytest`_ plugin to allow programmers write tests for `PySide`_ and `PyQt`_ applications. |
| 6 | + |
| 7 | +The main usage is to use the `qtbot` fixture, responsible for handling `qApp` |
| 8 | +creation as needed and provides methods to simulate user interaction, |
| 9 | +like key presses and mouse clicks: |
| 10 | + |
| 11 | + |
| 12 | +.. code-block:: python |
| 13 | +
|
| 14 | + def test_hello(qtbot): |
| 15 | + widget = HelloWidget() |
| 16 | + qtbot.addWidget(widget) |
| 17 | + |
| 18 | + # click in the Greet button and make sure it updates the appropriate label |
| 19 | + qtbot.mouseClick(window.button_greet, QtCore.Qt.LeftButton) |
| 20 | + |
| 21 | + assert window.greet_label.text() == 'Hello!' |
| 22 | +
|
| 23 | +
|
| 24 | +.. _PySide: https://pypi.python.org/pypi/PySide |
| 25 | +.. _PyQt: http://www.riverbankcomputing.com/software/pyqt |
| 26 | +.. _pytest: http://pytest.org |
| 27 | + |
| 28 | +This allows you to test and make sure your view layer is behaving the way you expect after each code change. |
| 29 | + |
| 30 | +|version| |downloads| |ci| |
| 31 | + |
| 32 | +.. |version| image:: http://img.shields.io/pypi/v/pytest-qt.png |
| 33 | + :target: https://crate.io/packages/pytest-qt |
| 34 | + |
| 35 | +.. |downloads| image:: http://img.shields.io/pypi/dm/pytest-qt.png |
| 36 | + :target: https://crate.io/packages/pytest-qt |
| 37 | + |
| 38 | +.. |ci| image:: http://img.shields.io/travis/nicoddemus/pytest-qt.png |
| 39 | + :target: https://travis-ci.org/nicoddemus/pytest-qt |
| 40 | + |
| 41 | + |
| 42 | +Requirements |
| 43 | +------------ |
| 44 | + |
| 45 | +Python 2.6 or later, including Python 3+. |
| 46 | + |
| 47 | +Works with either PySide_ or |
| 48 | +PyQt_ picking whichever is available on the system, giving |
| 49 | +preference to ``PySide`` if both are installed (to force it to use ``PyQt``, set |
| 50 | +the environment variable ``PYTEST_QT_FORCE_PYQT=true``). |
| 51 | + |
| 52 | +Documentation |
| 53 | +------------- |
| 54 | + |
| 55 | +Full documentation and tutorial available at `Read the Docs`_. |
| 56 | + |
| 57 | +.. _Read The Docs: https://pytest-qt.readthedocs.org/en/latest/ |
| 58 | + |
| 59 | +Change Log |
| 60 | +---------- |
| 61 | + |
| 62 | +Please consult the `releases page`_. |
| 63 | + |
| 64 | +.. _releases page: https://github.com/nicoddemus/pytest-qt/releases |
| 65 | + |
| 66 | +Bugs/Requests |
| 67 | +------------- |
| 68 | + |
| 69 | +Please report any issues or feature requests in the `issue tracker`_. |
| 70 | + |
| 71 | +.. _issue tracker: https://github.com/nicoddemus/pytest-qt/issues |
0 commit comments