Mon, 23 May 2022 17:18:58 +0200
Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
--- a/eric7/EricWidgets/EricPlainTextDialog.py Mon May 23 16:50:39 2022 +0200 +++ b/eric7/EricWidgets/EricPlainTextDialog.py Mon May 23 17:18:58 2022 +0200 @@ -18,16 +18,18 @@ """ Class implementing a dialog to show some plain text. """ - def __init__(self, title="", text="", parent=None): + def __init__(self, title="", text="", readOnly=True, parent=None): """ Constructor - @param title title of the window - @type str - @param text text to be shown - @type str - @param parent reference to the parent widget - @type QWidget + @param title title of the dialog (defaults to "") + @type str (optional) + @param text text to be shown (defaults to "") + @type str (optional) + @param readOnly flag indicating a read-only dialog (defaults to True) + @type bool (optional) + @param parent reference to the parent widget (defaults to None) + @type QWidget (optional) """ super().__init__(parent) self.setupUi(self) @@ -39,6 +41,7 @@ self.setWindowTitle(title) self.textEdit.setPlainText(text) + self.textEdit.setReadOnly(readOnly) @pyqtSlot() def on_copyButton_clicked(self): @@ -48,3 +51,12 @@ txt = self.textEdit.toPlainText() cb = QGuiApplication.clipboard() cb.setText(txt) + + def toPlainText(self): + """ + Public method to get the plain text. + + @return contents of the plain text edit + @rtype str + """ + return self.textEdit.toPlainText()
--- a/eric7/EricWidgets/EricPlainTextDialog.ui Mon May 23 16:50:39 2022 +0200 +++ b/eric7/EricWidgets/EricPlainTextDialog.ui Mon May 23 17:18:58 2022 +0200 @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>500</width> - <height>400</height> + <width>650</width> + <height>600</height> </rect> </property> <property name="windowTitle">
--- a/eric7/Testing/TestingWidget.py Mon May 23 16:50:39 2022 +0200 +++ b/eric7/Testing/TestingWidget.py Mon May 23 17:18:58 2022 +0200 @@ -100,6 +100,16 @@ self.testComboBox.lineEdit().setClearButtonEnabled(True) # create some more dialog buttons for orchestration + self.__showLogButton = self.buttonBox.addButton( + self.tr("Show Output..."), + QDialogButtonBox.ButtonRole.ActionRole) + self.__showLogButton.setToolTip( + self.tr("Show the output of the test runner process")) + self.__showLogButton.setWhatsThis(self.tr( + """<b>Show Output...</b""" + """<p>This button opens a dialog containing the output of the""" + """ test runner process of the most recent run.</p>""")) + self.__showCoverageButton = self.buttonBox.addButton( self.tr("Show Coverage..."), QDialogButtonBox.ButtonRole.ActionRole) @@ -174,6 +184,7 @@ self.__editors = [] self.__testExecutor = None + self.__recentLog = "" # connect some signals self.discoveryPicker.editTextChanged.connect( @@ -504,6 +515,9 @@ ) ) + # Log output button + self.__showLogButton.setEnabled(bool(self.__recentLog)) + # Close button self.buttonBox.button( QDialogButtonBox.StandardButton.Close @@ -633,6 +647,8 @@ self.startTests(failedOnly=True) elif button == self.__showCoverageButton: self.__showCoverageDialog() + elif button == self.__showLogButton: + self.__showLogOutput() @pyqtSlot(int) def on_venvComboBox_currentIndexChanged(self, index): @@ -736,6 +752,8 @@ if self.__mode == TestingWidgetModes.RUNNING: return + self.__recentLog = "" + self.__recentEnvironment = self.venvComboBox.currentText() self.__recentFramework = self.frameworkComboBox.currentText() @@ -912,6 +930,8 @@ @param output string containing the test process output (if any) @type str """ + self.__recentLog = output + self.__setStoppedMode() self.__testExecutor = None @@ -997,6 +1017,18 @@ self.__coverageDialog.show() self.__coverageDialog.start(self.__coverageFile, testDir) + @pyqtSlot() + def __showLogOutput(self): + """ + Private slot to show the output of the most recent test run. + """ + from EricWidgets.EricPlainTextDialog import EricPlainTextDialog + dlg = EricPlainTextDialog( + title=self.tr("Test Run Output"), + text=self.__recentLog + ) + dlg.exec() + @pyqtSlot(str) def __setStatusLabel(self, statusText): """