Exemplo n.º 1
0
    def test_view_logs_visible_to_caplog(self, caplog, qtbot):
        main_logger = applog.MainLogger()

        app_control = control.Controller(main_logger.log_queue)
        qtbot.wait(1000)

        app_control.close()
        time.sleep(1)

        main_logger.close()
        time.sleep(1)
        assert "Init of BasicWindow" in caplog.text()
        applog.explicit_log_close()
Exemplo n.º 2
0
    def run(self):
        """ This is the application code that is called by the main
        function. The architectural idea is to have as little code in
        main as possible and create the qapplication here so the
        testing code can function separately with pytest-qt.
        """
        self.app = QtGui.QApplication([])

        self.main_logger = applog.MainLogger()
        app_control = control.Controller(self.main_logger.log_queue)

        app_control.control_exit_signal.exit.connect(self.closeEvent)

        sys.exit(self.app.exec_())
Exemplo n.º 3
0
    def test_close_view_emits_control_signal(self, caplog, qtbot):
        """ Control script emits an event on a close condition to be processsed
        by the parent qt application, in this case qtbot. In the scripts file,
        it's the Qapplication.
        """
        main_logger = applog.MainLogger()
        app_control = control.Controller(main_logger.log_queue)

        QtTest.QTest.qWaitForWindowShown(app_control.form)

        signal = app_control.control_exit_signal.exit
        with qtbot.wait_signal(signal, timeout=1):
            app_control.form.close()

        main_logger.close()
        time.sleep(1)
        assert "Control level close" in caplog.text()
        applog.explicit_log_close()
Exemplo n.º 4
0
    def basic_window(self, qtbot, request, hardware=None):
        """ Setup the controller the same way the scripts/Application
        does at every test. Ensure that the teardown is in place
        regardless of test result.
        """
        main_logger = applog.MainLogger()

        app_control = control.Controller(main_logger.log_queue,
                                         hardware=hardware)

        qtbot.addWidget(app_control.form)

        def control_close():
            app_control.close()
            main_logger.close()
            applog.explicit_log_close()

        request.addfinalizer(control_close)

        return app_control