Exemplo n.º 1
0
def _process_events(item):
    """Calls app.processEvents() while taking care of capturing exceptions
    or not based on the given item's configuration.
    """
    app = QApplication.instance()
    if app is not None:
        if _is_exception_capture_disabled(item):
            app.processEvents()
        else:
            with capture_exceptions() as exceptions:
                app.processEvents()
            if exceptions:
                pytest.fail("TEARDOWN ERROR: " + format_captured_exceptions(exceptions), pytrace=False)
Exemplo n.º 2
0
def qtbot(qapp, request):
    """
    Fixture used to create a QtBot instance for using during testing.

    Make sure to call addWidget for each top-level widget you create to ensure
    that they are properly closed after the test ends.
    """
    result = QtBot()
    no_capture = _is_exception_capture_disabled(request.node)
    if no_capture:
        yield result  # pragma: no cover
    else:
        with capture_exceptions() as exceptions:
            yield result
        if exceptions:
            pytest.fail(format_captured_exceptions(exceptions), pytrace=False)

    result._close()