예제 #1
0
    def test_changedFontFamily(self):
        signalspy = QSignalSpy(self.ui.fontComboBox.currentIndexChanged)
        self.ui.fontComboBox.setCurrentIndex(2)

        # current connections for a signal
        self.assertEqual(
            self.ui.fontComboBox.receivers(
                self.ui.fontComboBox.currentIndexChanged), 1)

        self.assertEqual(len(signalspy), 1)
        self.assertTrue(signalspy.isValid())

        self.assertEqual(self.ui.fontComboBox.currentText(),
                         self.ui.bloodTextEdit.fontFamily())
        self.assertEqual(self.ui.fontComboBox.currentText(),
                         self.ui.renalTextEdit.fontFamily())
        self.assertEqual(self.ui.fontComboBox.currentText(),
                         self.ui.liverTextEdit.fontFamily())
        self.assertEqual(self.ui.fontComboBox.currentText(),
                         self.ui.thyroidTextEdit.fontFamily())
        self.assertEqual(self.ui.fontComboBox.currentText(),
                         self.ui.electrolyteTextEdit.fontFamily())
        self.assertEqual(self.ui.fontComboBox.currentText(),
                         self.ui.lipidTextEdit.fontFamily())

        self.ui.fontComboBox.setCurrentIndex(3)

        self.assertTrue(signalspy.isValid())
        self.assertEqual(len(signalspy), 2)

        self.assertEqual(
            self.ui.fontComboBox.receivers(
                self.ui.fontComboBox.currentIndexChanged), 1)

        self.assertEqual(self.ui.fontComboBox.currentText(),
                         self.ui.bloodTextEdit.fontFamily())
        self.assertEqual(self.ui.fontComboBox.currentText(),
                         self.ui.renalTextEdit.fontFamily())
        self.assertEqual(self.ui.fontComboBox.currentText(),
                         self.ui.liverTextEdit.fontFamily())
        self.assertEqual(self.ui.fontComboBox.currentText(),
                         self.ui.thyroidTextEdit.fontFamily())
        self.assertEqual(self.ui.fontComboBox.currentText(),
                         self.ui.electrolyteTextEdit.fontFamily())
        self.assertEqual(self.ui.fontComboBox.currentText(),
                         self.ui.lipidTextEdit.fontFamily())

        for signal in signalspy:
            print(
                "That was argument's value during setCurrentIndex (for font family change) execution: ",
                signal[0], "\n")
            print("So the font family changed to ",
                  self.ui.fontComboBox.itemText(signal[0]), "\n")
    def wait_for_completion(self, manager):
        spy = QSignalSpy(manager.allDownloaded)
        self.assertTrue(spy.isValid())
        manager.start()

        received = spy.wait(timeout=500)
        self.assertTrue(received)