eric6/PyUnit/UnittestDialog.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 8029
5feb4f723f07
child 8043
0acf98cd089a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7900
diff changeset
3 # Copyright (c) 2002 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the UI to the pyunit package.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import unittest
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import sys
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import time
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 import re
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 import os
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
16 from PyQt5.QtCore import pyqtSignal, QEvent, Qt, pyqtSlot
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
17 from PyQt5.QtGui import QColor
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
18 from PyQt5.QtWidgets import (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
19 QWidget, QDialog, QApplication, QDialogButtonBox, QListWidgetItem,
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
20 QComboBox, QTreeWidgetItem
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
21 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 53
diff changeset
23 from E5Gui.E5Application import e5App
4582
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
24 from E5Gui import E5MessageBox
2101
5bac7dee9e1a Introduced the E5MainWindow class allowing to set a style for all the main windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1782
diff changeset
25 from E5Gui.E5MainWindow import E5MainWindow
4582
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
26 from E5Gui.E5PathPicker import E5PathPickerModes
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
28 from .Ui_UnittestDialog import Ui_UnittestDialog
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 import UI.PixmapCache
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
1166
a94b0a2fafd7 Extended the unit test interface to support skipped tests, expected failures and unexpected successes and to better cope with Python2 scripts when run from the eric IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
32 import Preferences
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
34
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 class UnittestDialog(QWidget, Ui_UnittestDialog):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 Class implementing the UI to the pyunit package.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
39 @signal unittestFile(str, int, bool) emitted to show the source of a
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
40 unittest file
1499
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
41 @signal unittestStopped() emitted after a unit test was run
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 """
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
43 unittestFile = pyqtSignal(str, int, bool)
1499
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
44 unittestStopped = pyqtSignal()
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 481
diff changeset
45
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
46 TestCaseNameRole = Qt.UserRole
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
47 TestCaseFileRole = Qt.UserRole + 1
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
48
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
49 ErrorsInfoRole = Qt.UserRole
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
50
8029
5feb4f723f07 UnittestDialog: changed color handling to support dark themes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7960
diff changeset
51 SkippedColorDarkTheme = QColor("#00aaff")
5feb4f723f07 UnittestDialog: changed color handling to support dark themes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7960
diff changeset
52 FailedExpectedColorDarkTheme = QColor("#ccaaff")
5feb4f723f07 UnittestDialog: changed color handling to support dark themes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7960
diff changeset
53 SucceededUnexpectedColorDarkTheme = QColor("#ff99dd")
5feb4f723f07 UnittestDialog: changed color handling to support dark themes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7960
diff changeset
54 SkippedColorLightTheme = QColor("#0000ff")
5feb4f723f07 UnittestDialog: changed color handling to support dark themes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7960
diff changeset
55 FailedExpectedColorLightTheme = QColor("#7700bb")
5feb4f723f07 UnittestDialog: changed color handling to support dark themes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7960
diff changeset
56 SucceededUnexpectedColorLightTheme = QColor("#ff0000")
5feb4f723f07 UnittestDialog: changed color handling to support dark themes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7960
diff changeset
57
6888
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
58 def __init__(self, prog=None, dbs=None, ui=None, parent=None, name=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 @param prog filename of the program to open
6888
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
63 @type str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 @param dbs reference to the debug server object. It is an indication
7960
e8fc383322f7 Harmonized some user visible strings and changed the term 'eric6' to the more generic 'eric'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
65 whether we were called from within the eric IDE.
6888
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
66 @type DebugServer
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 @param ui reference to the UI object
6888
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
68 @type UserInterface
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
69 @param parent parent widget of this dialog
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
70 @type QWidget
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
71 @param name name of this dialog
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
72 @type str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2409
diff changeset
74 super(UnittestDialog, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 if name:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.setObjectName(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
4582
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
79 self.testsuitePicker.setMode(E5PathPickerModes.OpenFileMode)
4589
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4582
diff changeset
80 self.testsuitePicker.setInsertPolicy(QComboBox.InsertAtTop)
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4582
diff changeset
81 self.testsuitePicker.setSizeAdjustPolicy(
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4582
diff changeset
82 QComboBox.AdjustToMinimumContentsLength)
3186
a05eff845522 Changed all the file or directory selection buttons to QToolButton and gave them an icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
83
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
84 self.discoveryPicker.setMode(E5PathPickerModes.DirectoryMode)
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
85 self.discoveryPicker.setInsertPolicy(QComboBox.InsertAtTop)
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
86 self.discoveryPicker.setSizeAdjustPolicy(
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
87 QComboBox.AdjustToMinimumContentsLength)
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
88
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
89 self.discoverButton = self.buttonBox.addButton(
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
90 self.tr("Discover"), QDialogButtonBox.ActionRole)
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
91 self.discoverButton.setToolTip(self.tr(
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
92 "Discover tests"))
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
93 self.discoverButton.setWhatsThis(self.tr(
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
94 """<b>Discover</b>"""
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
95 """<p>This button starts a discovery of available tests.</p>"""))
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
96 self.startButton = self.buttonBox.addButton(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
97 self.tr("Start"), QDialogButtonBox.ActionRole)
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
98 self.startButton.setToolTip(self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
99 "Start the selected testsuite"))
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
100 self.startButton.setWhatsThis(self.tr(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 """<b>Start Test</b>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 """<p>This button starts the selected testsuite.</p>"""))
1499
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
103 self.startFailedButton = self.buttonBox.addButton(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
104 self.tr("Rerun Failed"), QDialogButtonBox.ActionRole)
1499
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
105 self.startFailedButton.setToolTip(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
106 self.tr("Reruns failed tests of the selected testsuite"))
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
107 self.startFailedButton.setWhatsThis(self.tr(
1499
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
108 """<b>Rerun Failed</b>"""
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
109 """<p>This button reruns all failed tests of the selected"""
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
110 """ testsuite.</p>"""))
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
111 self.stopButton = self.buttonBox.addButton(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
112 self.tr("Stop"), QDialogButtonBox.ActionRole)
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
113 self.stopButton.setToolTip(self.tr("Stop the running unittest"))
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
114 self.stopButton.setWhatsThis(self.tr(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 """<b>Stop Test</b>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 """<p>This button stops a running unittest.</p>"""))
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
117 self.discoverButton.setEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 self.stopButton.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 self.startButton.setDefault(True)
1499
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
120 self.startFailedButton.setEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121
6888
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
122 self.__dbs = dbs
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
123 self.__forProject = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
125 self.setWindowFlags(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
126 self.windowFlags() | Qt.WindowFlags(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
127 Qt.WindowContextHelpButtonHint))
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
128 self.setWindowIcon(UI.PixmapCache.getIcon("eric"))
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
129 self.setWindowTitle(self.tr("Unittest"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 if dbs:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 self.ui = ui
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
132
6904
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6902
diff changeset
133 self.debuggerCheckBox.setChecked(True)
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6902
diff changeset
134
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
135 # virtual environment manager is only used in the integrated
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
136 # variant
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
137 self.__venvManager = e5App().getObject("VirtualEnvManager")
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
138 self.__populateVenvComboBox()
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
139 self.__venvManager.virtualEnvironmentAdded.connect(
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
140 self.__populateVenvComboBox)
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
141 self.__venvManager.virtualEnvironmentRemoved.connect(
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
142 self.__populateVenvComboBox)
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
143 self.__venvManager.virtualEnvironmentChanged.connect(
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
144 self.__populateVenvComboBox)
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
145 else:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
146 self.__venvManager = None
6904
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6902
diff changeset
147 self.debuggerCheckBox.setVisible(False)
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
148 self.venvComboBox.setVisible(bool(self.__venvManager))
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
149 self.venvLabel.setVisible(bool(self.__venvManager))
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
150
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 self.__setProgressColor("green")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 self.progressLed.setDarkFactor(150)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 self.progressLed.off()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
155 self.discoverHistory = []
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 self.fileHistory = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 self.testNameHistory = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 self.running = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 self.savedModulelist = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 self.savedSysPath = sys.path
6897
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
161 self.savedCwd = os.getcwd()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 if prog:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 self.insertProg(prog)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164
1166
a94b0a2fafd7 Extended the unit test interface to support skipped tests, expected failures and unexpected successes and to better cope with Python2 scripts when run from the eric IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
165 self.rxPatterns = [
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
166 self.tr("^Failure: "),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
167 self.tr("^Error: "),
5409
c6f4a6f0d051 Fixed a situation in the unittest dialog where translations are only partially done.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
168 # These are for untranslated/partially translated situations
c6f4a6f0d051 Fixed a situation in the unittest dialog where translations are only partially done.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
169 "^Failure: ",
c6f4a6f0d051 Fixed a situation in the unittest dialog where translations are only partially done.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
170 "^Error: ",
1166
a94b0a2fafd7 Extended the unit test interface to support skipped tests, expected failures and unexpected successes and to better cope with Python2 scripts when run from the eric IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
171 ]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172
1499
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
173 self.__failedTests = []
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
174
7960
e8fc383322f7 Harmonized some user visible strings and changed the term 'eric6' to the more generic 'eric'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
175 # now connect the debug server signals if called from the eric IDE
6888
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
176 if self.__dbs:
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
177 self.__dbs.utDiscovered.connect(self.__UTDiscovered)
6888
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
178 self.__dbs.utPrepared.connect(self.__UTPrepared)
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
179 self.__dbs.utFinished.connect(self.__setStoppedMode)
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
180 self.__dbs.utStartTest.connect(self.testStarted)
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
181 self.__dbs.utStopTest.connect(self.testFinished)
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
182 self.__dbs.utTestFailed.connect(self.testFailed)
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
183 self.__dbs.utTestErrored.connect(self.testErrored)
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
184 self.__dbs.utTestSkipped.connect(self.testSkipped)
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
185 self.__dbs.utTestFailedExpected.connect(self.testFailedExpected)
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
186 self.__dbs.utTestSucceededUnexpected.connect(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
187 self.testSucceededUnexpected)
6359
e78be0616e6e Unit test: extended the standalone unit test tool to be able to open source in an editor window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
188
e78be0616e6e Unit test: extended the standalone unit test tool to be able to open source in an editor window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
189 self.__editors = []
1481
eebaadaee21e Added the function to close the unit test dialog by pressing the Esc key.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1166
diff changeset
190
eebaadaee21e Added the function to close the unit test dialog by pressing the Esc key.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1166
diff changeset
191 def keyPressEvent(self, evt):
eebaadaee21e Added the function to close the unit test dialog by pressing the Esc key.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1166
diff changeset
192 """
eebaadaee21e Added the function to close the unit test dialog by pressing the Esc key.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1166
diff changeset
193 Protected slot to handle key press events.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194
1481
eebaadaee21e Added the function to close the unit test dialog by pressing the Esc key.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1166
diff changeset
195 @param evt key press event to handle (QKeyEvent)
eebaadaee21e Added the function to close the unit test dialog by pressing the Esc key.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1166
diff changeset
196 """
6888
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
197 if evt.key() == Qt.Key_Escape and self.__dbs:
1481
eebaadaee21e Added the function to close the unit test dialog by pressing the Esc key.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1166
diff changeset
198 self.close()
eebaadaee21e Added the function to close the unit test dialog by pressing the Esc key.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1166
diff changeset
199
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
200 def __populateVenvComboBox(self):
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
201 """
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
202 Private method to (re-)populate the virtual environments selector.
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
203 """
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
204 currentText = self.venvComboBox.currentText()
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
205 self.venvComboBox.clear()
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
206 self.venvComboBox.addItem("")
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
207 self.venvComboBox.addItems(
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
208 sorted(self.__venvManager.getVirtualenvNames()))
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
209 index = self.venvComboBox.findText(currentText)
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
210 if index < 0:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
211 index = 0
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
212 self.venvComboBox.setCurrentIndex(index)
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
213
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 def __setProgressColor(self, color):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 Private methode to set the color of the progress color label.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 @param color colour to be shown (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 self.progressLed.setColor(QColor(color))
6888
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
221
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
222 def setProjectMode(self, forProject):
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
223 """
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
224 Public method to set the project mode of the dialog.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225
6888
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
226 @param forProject flag indicating to run for the open project
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
227 @type bool
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
228 """
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
229 self.__forProject = forProject
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
230 if forProject:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
231 project = e5App().getObject("Project")
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
232 if project.isOpen():
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
233 self.insertDiscovery(project.getProjectPath())
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
234 else:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
235 self.insertDiscovery("")
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
236 else:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
237 self.insertDiscovery("")
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
238
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
239 self.discoveryList.clear()
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
240 self.tabWidget.setCurrentIndex(0)
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
241
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
242 def insertDiscovery(self, start):
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
243 """
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
244 Public slot to insert the discovery start directory into the
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
245 discoveryPicker object.
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
246
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
247 @param start start directory name to be inserted
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
248 @type str
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
249 """
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
250 # prepend the given directory to the discovery picker
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
251 if start is None:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
252 start = ""
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
253 if start in self.discoverHistory:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
254 self.discoverHistory.remove(start)
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
255 self.discoverHistory.insert(0, start)
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
256 self.discoveryPicker.clear()
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
257 self.discoveryPicker.addItems(self.discoverHistory)
6888
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
258
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 def insertProg(self, prog):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 """
4582
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
261 Public slot to insert the filename prog into the testsuitePicker
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
262 object.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 @param prog filename to be inserted (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 """
4582
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
266 # prepend the selected file to the testsuite picker
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 if prog is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 prog = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 if prog in self.fileHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 self.fileHistory.remove(prog)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 self.fileHistory.insert(0, prog)
4582
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
272 self.testsuitePicker.clear()
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
273 self.testsuitePicker.addItems(self.fileHistory)
6893
d29a7b8fab0f UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
274
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 def insertTestName(self, testName):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 Public slot to insert a test name into the testComboBox object.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 @param testName name of the test to be inserted (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 # prepend the selected file to the testsuite combobox
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 if testName is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 testName = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 if testName in self.testNameHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 self.testNameHistory.remove(testName)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 self.testNameHistory.insert(0, testName)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 self.testComboBox.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 self.testComboBox.addItems(self.testNameHistory)
6893
d29a7b8fab0f UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
289
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 @pyqtSlot()
4582
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
291 def on_testsuitePicker_aboutToShowPathPickerDialog(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 """
4582
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
293 Private slot called before the test suite selection dialog is shown.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 """
6888
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
295 if self.__dbs:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
296 py3Extensions = ' '.join(
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
297 ["*{0}".format(ext)
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
298 for ext in self.__dbs.getExtensions('Python3')]
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
299 )
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5409
diff changeset
300 fileFilter = self.tr(
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
301 "Python3 Files ({0});;All Files (*)"
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
302 ).format(py3Extensions)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 else:
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5409
diff changeset
304 fileFilter = self.tr("Python Files (*.py);;All Files (*)")
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5409
diff changeset
305 self.testsuitePicker.setFilters(fileFilter)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306
6893
d29a7b8fab0f UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
307 defaultDirectory = Preferences.getMultiProject("Workspace")
d29a7b8fab0f UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
308 if not defaultDirectory:
d29a7b8fab0f UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
309 defaultDirectory = os.path.expanduser("~")
d29a7b8fab0f UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
310 if self.__dbs:
d29a7b8fab0f UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
311 project = e5App().getObject("Project")
d29a7b8fab0f UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
312 if self.__forProject and project.isOpen():
d29a7b8fab0f UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
313 defaultDirectory = project.getProjectPath()
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
314 self.testsuitePicker.setDefaultDirectory(defaultDirectory)
6893
d29a7b8fab0f UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
315
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 @pyqtSlot(str)
4582
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
317 def on_testsuitePicker_pathSelected(self, suite):
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
318 """
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
319 Private slot called after a test suite has been selected.
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
320
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
321 @param suite file name of the test suite
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
322 @type str
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
323 """
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
324 self.insertProg(suite)
6893
d29a7b8fab0f UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
325
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
326 @pyqtSlot(str)
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
327 def on_testsuitePicker_editTextChanged(self, path):
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
328 """
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
329 Private slot handling changes of the test suite path.
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
330
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
331 @param path path of the test suite file
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
332 @type str
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
333 """
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
334 self.startFailedButton.setEnabled(False)
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
335
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
336 @pyqtSlot(bool)
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
337 def on_discoverCheckBox_toggled(self, checked):
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
338 """
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
339 Private slot handling state changes of the 'discover' checkbox.
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
340
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
341 @param checked state of the checkbox
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
342 @type bool
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
343 """
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
344 self.discoverButton.setEnabled(checked)
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
345 self.discoveryList.clear()
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
346
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
347 if not bool(self.discoveryPicker.currentText()):
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
348 if self.__forProject:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
349 project = e5App().getObject("Project")
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
350 if project.isOpen():
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
351 self.insertDiscovery(project.getProjectPath())
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
352 return
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
353
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
354 self.insertDiscovery(Preferences.getMultiProject("Workspace"))
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
355
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 def on_buttonBox_clicked(self, button):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 Private slot called by a button of the button box clicked.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 @param button button that was clicked (QAbstractButton)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 """
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
362 if button == self.discoverButton:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
363 self.__discover()
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
364 elif button == self.startButton:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
365 self.startTests()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 elif button == self.stopButton:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
367 self.__stopTests()
1499
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
368 elif button == self.startFailedButton:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
369 self.startTests(failedOnly=True)
6893
d29a7b8fab0f UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
370
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 @pyqtSlot()
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
372 def __discover(self):
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
373 """
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
374 Private slot to discover unit test but don't run them.
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
375 """
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
376 if self.running:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
377 return
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
378
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
379 self.discoveryList.clear()
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
380
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
381 discoveryStart = self.discoveryPicker.currentText()
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
382 self.sbLabel.setText(self.tr("Discovering Tests"))
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
383 QApplication.processEvents()
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
384
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
385 self.testName = self.tr("Unittest with auto-discovery")
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
386 if self.__dbs:
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
387 venvName = self.venvComboBox.currentText()
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
388
7960
e8fc383322f7 Harmonized some user visible strings and changed the term 'eric6' to the more generic 'eric'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
389 # we are cooperating with the eric IDE
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
390 project = e5App().getObject("Project")
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
391 if self.__forProject:
7072
66ef92f769bf Allow unittest for projects without main script.
Mikhail Terekhov
parents: 7071
diff changeset
392 mainScript = project.getMainScript(True)
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
393 clientType = project.getProjectLanguage()
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
394 if mainScript:
7072
66ef92f769bf Allow unittest for projects without main script.
Mikhail Terekhov
parents: 7071
diff changeset
395 workdir = os.path.dirname(os.path.abspath(mainScript))
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
396 else:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
397 workdir = project.getProjectPath()
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
398 sysPath = [workdir]
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
399 if not discoveryStart:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
400 discoveryStart = workdir
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
401 else:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
402 if not discoveryStart:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
403 E5MessageBox.critical(
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
404 self,
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
405 self.tr("Unittest"),
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
406 self.tr("You must enter a start directory for"
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
407 " auto-discovery."))
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
408 return
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
409
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
410 workdir = ""
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
411 clientType = "Python3"
6905
889339ffe6cf UnittestDialog: fixed an issue causing an uncaught exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6904
diff changeset
412 sysPath = []
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
413 self.__dbs.remoteUTDiscover(clientType, self.__forProject,
7071
c9ff30a1acbb Fix unittest discovery, allow discovery start in project subdirectory.
Mikhail Terekhov
parents: 6942
diff changeset
414 venvName, sysPath, workdir,
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
415 discoveryStart)
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
416 else:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
417 # we are running as an application
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
418 if not discoveryStart:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
419 E5MessageBox.critical(
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
420 self,
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
421 self.tr("Unittest"),
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
422 self.tr("You must enter a start directory for"
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
423 " auto-discovery."))
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
424 return
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
425
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
426 if discoveryStart:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
427 sys.path = (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
428 [os.path.abspath(discoveryStart)] +
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
429 self.savedSysPath
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
430 )
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
431
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
432 # clean up list of imported modules to force a reimport upon
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
433 # running the test
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
434 if self.savedModulelist:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
435 for modname in list(sys.modules.keys()):
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
436 if modname not in self.savedModulelist:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
437 # delete it
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
438 del(sys.modules[modname])
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
439 self.savedModulelist = sys.modules.copy()
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
440
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
441 # now try to discover the testsuite
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
442 os.chdir(discoveryStart)
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
443 try:
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
444 testLoader = unittest.TestLoader()
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
445 test = testLoader.discover(discoveryStart)
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
446 if hasattr(testLoader, "errors") and bool(testLoader.errors):
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
447 E5MessageBox.critical(
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
448 self,
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
449 self.tr("Unittest"),
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
450 self.tr(
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
451 "<p>Unable to discover tests.</p>"
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
452 "<p>{0}</p>"
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
453 ).format("<br/>".join(testLoader.errors)
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
454 .replace("\n", "<br/>"))
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
455 )
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
456 self.sbLabel.clear()
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
457 else:
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
458 testsList = self.__assembleTestCasesList(
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
459 test, discoveryStart)
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
460 self.__populateDiscoveryResults(testsList)
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
461 self.sbLabel.setText(
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
462 self.tr("Discovered %n Test(s)", "",
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
463 len(testsList)))
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
464 self.tabWidget.setCurrentIndex(0)
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
465 except Exception:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
466 exc_type, exc_value, exc_tb = sys.exc_info()
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
467 E5MessageBox.critical(
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
468 self,
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
469 self.tr("Unittest"),
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
470 self.tr(
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
471 "<p>Unable to discover tests.</p>"
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
472 "<p>{0}<br/>{1}</p>")
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
473 .format(str(exc_type),
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
474 str(exc_value).replace("\n", "<br/>"))
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
475 )
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
476 self.sbLabel.clear()
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
477
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
478 sys.path = self.savedSysPath
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
479
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
480 def __assembleTestCasesList(self, suite, start):
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
481 """
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
482 Private method to assemble a list of test cases included in a test
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
483 suite.
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
484
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
485 @param suite test suite to be inspected
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
486 @type unittest.TestSuite
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
487 @param start name of directory discovery was started at
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
488 @type str
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
489 @return list of tuples containing the test case ID, a short description
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
490 and the path of the test file name
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
491 @rtype list of tuples of (str, str, str)
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
492 """
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
493 testCases = []
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
494 for test in suite:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
495 if isinstance(test, unittest.TestSuite):
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
496 testCases.extend(self.__assembleTestCasesList(test, start))
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
497 else:
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
498 testId = test.id()
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
499 if (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
500 "ModuleImportFailure" not in testId and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
501 "LoadTestsFailure" not in testId and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
502 "_FailedTest" not in testId
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
503 ):
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
504 filename = os.path.join(
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
505 start,
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
506 test.__module__.replace(".", os.sep) + ".py")
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
507 testCases.append(
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
508 (test.id(), test.shortDescription(), filename)
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
509 )
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
510 return testCases
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
511
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
512 def __findDiscoveryItem(self, modulePath):
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
513 """
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
514 Private method to find an item given the module path.
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
515
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
516 @param modulePath path of the module in dotted notation
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
517 @type str
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
518 @return reference to the item or None
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
519 @rtype QTreeWidgetItem or None
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
520 """
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
521 itm = self.discoveryList.topLevelItem(0)
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
522 while itm is not None:
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
523 if itm.data(0, UnittestDialog.TestCaseNameRole) == modulePath:
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
524 return itm
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
525 itm = self.discoveryList.itemBelow(itm)
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
526
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
527 return None
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
528
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
529 def __populateDiscoveryResults(self, tests):
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
530 """
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
531 Private method to populate the test discovery results list.
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
532
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
533 @param tests list of tuples containing the discovery results
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
534 @type list of tuples of (str, str, str)
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
535 """
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
536 for test, _testDescription, filename in tests:
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
537 testPath = test.split(".")
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
538 pitm = None
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
539 for index in range(1, len(testPath) + 1):
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
540 modulePath = ".".join(testPath[:index])
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
541 itm = self.__findDiscoveryItem(modulePath)
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
542 if itm is not None:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
543 pitm = itm
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
544 else:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
545 if pitm is None:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
546 itm = QTreeWidgetItem(self.discoveryList,
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
547 [testPath[index - 1]])
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
548 else:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
549 itm = QTreeWidgetItem(pitm,
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
550 [testPath[index - 1]])
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
551 pitm.setExpanded(True)
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
552 itm.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
553 itm.setCheckState(0, Qt.Unchecked)
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
554 itm.setData(0, UnittestDialog.TestCaseNameRole, modulePath)
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
555 if (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
556 os.path.splitext(os.path.basename(filename))[0] ==
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
557 itm.text(0)
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
558 ):
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
559 itm.setData(0, UnittestDialog.TestCaseFileRole,
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
560 filename)
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
561 elif pitm:
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
562 fn = pitm.data(0, UnittestDialog.TestCaseFileRole)
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
563 if fn:
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
564 itm.setData(0, UnittestDialog.TestCaseFileRole, fn)
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
565 pitm = itm
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
566
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
567 def __selectedTestCases(self, parent=None):
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
568 """
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
569 Private method to assemble the list of selected test cases and suites.
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
570
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
571 @param parent reference to the parent item
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
572 @type QTreeWidgetItem
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
573 @return list of selected test cases
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
574 @rtype list of str
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
575 """
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
576 selectedTests = []
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
577 if parent is None:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
578 # top level
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
579 for index in range(self.discoveryList.topLevelItemCount()):
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
580 itm = self.discoveryList.topLevelItem(index)
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
581 if itm.checkState(0) == Qt.Checked:
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
582 selectedTests.append(
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
583 itm.data(0, UnittestDialog.TestCaseNameRole))
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
584 # ignore children because they are included implicitly
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
585 elif itm.childCount():
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
586 # recursively check children
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
587 selectedTests.extend(self.__selectedTestCases(itm))
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
588
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
589 else:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
590 # parent item with children
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
591 for index in range(parent.childCount()):
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
592 itm = parent.child(index)
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
593 if itm.checkState(0) == Qt.Checked:
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
594 selectedTests.append(
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
595 itm.data(0, UnittestDialog.TestCaseNameRole))
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
596 # ignore children because they are included implicitly
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
597 elif itm.childCount():
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
598 # recursively check children
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
599 selectedTests.extend(self.__selectedTestCases(itm))
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
600
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
601 return selectedTests
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
602
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
603 def __UTDiscovered(self, testCases, exc_type, exc_value):
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
604 """
6904
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6902
diff changeset
605 Private slot to handle the utDiscovered signal.
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
606
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
607 If the unittest suite was loaded successfully, we ask the
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
608 client to run the test suite.
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
609
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
610 @param testCases list of detected test cases
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
611 @type str
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
612 @param exc_type exception type occured during discovery
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
613 @type str
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
614 @param exc_value value of exception occured during discovery
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
615 @type str
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
616 """
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
617 if testCases:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
618 self.__populateDiscoveryResults(testCases)
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
619 self.sbLabel.setText(
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
620 self.tr("Discovered %n Test(s)", "",
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
621 len(testCases)))
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
622 self.tabWidget.setCurrentIndex(0)
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
623 else:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
624 E5MessageBox.critical(
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
625 self,
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
626 self.tr("Unittest"),
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
627 self.tr("<p>Unable to discover tests.</p>"
6902
67d0ad66b59a Updated translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
628 "<p>{0}<br/>{1}</p>")
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
629 .format(exc_type, exc_value.replace("\n", "<br/>"))
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
630 )
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
631
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
632 @pyqtSlot(QTreeWidgetItem, int)
7073
e86027967f5c Recursively change children's check state when an item check state is changed
Mikhail Terekhov
parents: 7072
diff changeset
633 def on_discoveryList_itemChanged(self, item, column):
e86027967f5c Recursively change children's check state when an item check state is changed
Mikhail Terekhov
parents: 7072
diff changeset
634 """
e86027967f5c Recursively change children's check state when an item check state is changed
Mikhail Terekhov
parents: 7072
diff changeset
635 Private slot handling the user checking or unchecking an item.
e86027967f5c Recursively change children's check state when an item check state is changed
Mikhail Terekhov
parents: 7072
diff changeset
636
e86027967f5c Recursively change children's check state when an item check state is changed
Mikhail Terekhov
parents: 7072
diff changeset
637 @param item reference to the item
e86027967f5c Recursively change children's check state when an item check state is changed
Mikhail Terekhov
parents: 7072
diff changeset
638 @type QTreeWidgetItem
e86027967f5c Recursively change children's check state when an item check state is changed
Mikhail Terekhov
parents: 7072
diff changeset
639 @param column changed column
e86027967f5c Recursively change children's check state when an item check state is changed
Mikhail Terekhov
parents: 7072
diff changeset
640 @type int
e86027967f5c Recursively change children's check state when an item check state is changed
Mikhail Terekhov
parents: 7072
diff changeset
641 """
e86027967f5c Recursively change children's check state when an item check state is changed
Mikhail Terekhov
parents: 7072
diff changeset
642 if column == 0:
e86027967f5c Recursively change children's check state when an item check state is changed
Mikhail Terekhov
parents: 7072
diff changeset
643 for index in range(item.childCount()):
e86027967f5c Recursively change children's check state when an item check state is changed
Mikhail Terekhov
parents: 7072
diff changeset
644 item.child(index).setCheckState(0, item.checkState(0))
e86027967f5c Recursively change children's check state when an item check state is changed
Mikhail Terekhov
parents: 7072
diff changeset
645
e86027967f5c Recursively change children's check state when an item check state is changed
Mikhail Terekhov
parents: 7072
diff changeset
646 @pyqtSlot(QTreeWidgetItem, int)
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
647 def on_discoveryList_itemDoubleClicked(self, item, column):
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
648 """
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
649 Private slot handling the user double clicking an item.
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
650
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
651 @param item reference to the item
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
652 @type QTreeWidgetItem
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
653 @param column column of the double click
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
654 @type int
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
655 """
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
656 if item:
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
657 filename = item.data(0, UnittestDialog.TestCaseFileRole)
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
658 if filename:
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
659 if self.__dbs:
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
660 # running as part of eric IDE
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
661 self.unittestFile.emit(filename, 1, False)
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
662 else:
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
663 self.__openEditor(filename, 1)
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
664
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
665 @pyqtSlot()
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
666 def startTests(self, failedOnly=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
667 """
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
668 Public slot to start the test.
1499
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
669
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
670 @param failedOnly flag indicating to run only failed tests (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
671 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
672 if self.running:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
673 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
674
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
675 discover = self.discoverCheckBox.isChecked()
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
676 if discover:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
677 discoveryStart = self.discoveryPicker.currentText()
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
678 testFileName = ""
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
679 testName = ""
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
680 else:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
681 discoveryStart = ""
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
682 testFileName = self.testsuitePicker.currentText()
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
683 testName = self.testComboBox.currentText()
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
684 if testName:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
685 self.insertTestName(testName)
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
686 if testFileName and not testName:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
687 testName = "suite"
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
688
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
689 if not discover and not testFileName and not testName:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
690 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
691 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
692 self.tr("Unittest"),
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
693 self.tr("You must select auto-discovery or enter a test suite"
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
694 " file or a dotted test name."))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
695 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
696
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
697 # prepend the selected file to the testsuite combobox
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
698 self.insertProg(testFileName)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
699 self.sbLabel.setText(self.tr("Preparing Testsuite"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
700 QApplication.processEvents()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
701
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
702 if discover:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
703 self.testName = self.tr("Unittest with auto-discovery")
1000
c9f094c33a1d Fixed an issue with the unittest dialog not remembering the entered test name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
704 else:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
705 # build the module name from the filename without extension
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
706 if testFileName:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
707 self.testName = os.path.splitext(
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
708 os.path.basename(testFileName))[0]
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
709 elif testName:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
710 self.testName = testName
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
711 else:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
712 self.testName = self.tr("<Unnamed Test>")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
713
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
714 if failedOnly:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
715 testCases = []
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
716 else:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
717 testCases = self.__selectedTestCases()
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
718
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
719 if not testCases and self.discoveryList.topLevelItemCount():
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
720 ok = E5MessageBox.yesNo(
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
721 self,
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
722 self.tr("Unittest"),
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
723 self.tr("""No test case has been selected. Shall all"""
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
724 """ test cases be run?"""))
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
725 if not ok:
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
726 return
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
727
6892
c147620313c5 UnittestDialog: fixed an issue running tests for a project and removed the (obsolete) 'local' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6890
diff changeset
728 if self.__dbs:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
729 venvName = self.venvComboBox.currentText()
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
730
7960
e8fc383322f7 Harmonized some user visible strings and changed the term 'eric6' to the more generic 'eric'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
731 # we are cooperating with the eric IDE
53
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 34
diff changeset
732 project = e5App().getObject("Project")
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
733 if self.__forProject:
7072
66ef92f769bf Allow unittest for projects without main script.
Mikhail Terekhov
parents: 7071
diff changeset
734 mainScript = project.getMainScript(True)
1782
90bd49fec9ff Fixed an issue in the unit test dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
735 clientType = project.getProjectLanguage()
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
736 if mainScript:
7072
66ef92f769bf Allow unittest for projects without main script.
Mikhail Terekhov
parents: 7071
diff changeset
737 workdir = os.path.dirname(os.path.abspath(mainScript))
66ef92f769bf Allow unittest for projects without main script.
Mikhail Terekhov
parents: 7071
diff changeset
738 coverageFile = os.path.splitext(mainScript)[0]
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
739 else:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
740 workdir = project.getProjectPath()
7072
66ef92f769bf Allow unittest for projects without main script.
Mikhail Terekhov
parents: 7071
diff changeset
741 coverageFile = os.path.join(discoveryStart, "unittest")
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
742 sysPath = [workdir]
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
743 if discover and not discoveryStart:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
744 discoveryStart = workdir
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
745 else:
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
746 if discover:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
747 if not discoveryStart:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
748 E5MessageBox.critical(
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
749 self,
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
750 self.tr("Unittest"),
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
751 self.tr("You must enter a start directory for"
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
752 " auto-discovery."))
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
753 return
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
754
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
755 coverageFile = os.path.join(discoveryStart, "unittest")
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
756 workdir = ""
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
757 clientType = "Python3"
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
758 elif testFileName:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
759 mainScript = os.path.abspath(testFileName)
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
760 workdir = os.path.dirname(mainScript)
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
761 clientType = "Python3"
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
762 coverageFile = os.path.splitext(mainScript)[0]
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
763 else:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
764 coverageFile = os.path.abspath("unittest")
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
765 workdir = ""
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
766 clientType = "Python3"
6892
c147620313c5 UnittestDialog: fixed an issue running tests for a project and removed the (obsolete) 'local' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6890
diff changeset
767 sysPath = []
6897
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
768 if failedOnly and self.__failedTests:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
769 failed = self.__failedTests[:]
6897
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
770 if discover:
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
771 workdir = discoveryStart
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
772 discover = False
1499
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
773 else:
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
774 failed = []
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
775 self.__failedTests = []
6888
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
776 self.__dbs.remoteUTPrepare(
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
777 testFileName, self.testName, testName, failed,
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
778 self.coverageCheckBox.isChecked(), coverageFile,
6888
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
779 self.coverageEraseCheckBox.isChecked(), clientType=clientType,
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
780 forProject=self.__forProject, workdir=workdir,
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
781 venvName=venvName, syspath=sysPath,
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
782 discover=discover, discoveryStart=discoveryStart,
6904
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6902
diff changeset
783 testCases=testCases, debug=self.debuggerCheckBox.isChecked())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
784 else:
6892
c147620313c5 UnittestDialog: fixed an issue running tests for a project and removed the (obsolete) 'local' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6890
diff changeset
785 # we are running as an application
6897
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
786 if discover and not discoveryStart:
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
787 E5MessageBox.critical(
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
788 self,
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
789 self.tr("Unittest"),
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
790 self.tr("You must enter a start directory for"
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
791 " auto-discovery."))
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
792 return
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
793
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
794 if testFileName:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
795 sys.path = (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
796 [os.path.dirname(os.path.abspath(testFileName))] +
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
797 self.savedSysPath
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
798 )
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
799 elif discoveryStart:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
800 sys.path = (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
801 [os.path.abspath(discoveryStart)] +
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
802 self.savedSysPath
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
803 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
804
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
805 # clean up list of imported modules to force a reimport upon
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
806 # running the test
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
807 if self.savedModulelist:
34
93367928a93b Ported the unittest dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
808 for modname in list(sys.modules.keys()):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
809 if modname not in self.savedModulelist:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
810 # delete it
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
811 del(sys.modules[modname])
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
812 self.savedModulelist = sys.modules.copy()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
813
6897
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
814 os.chdir(self.savedCwd)
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
815
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
816 # now try to generate the testsuite
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
817 try:
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
818 testLoader = unittest.TestLoader()
6897
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
819 if failedOnly and self.__failedTests:
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
820 failed = self.__failedTests[:]
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
821 if discover:
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
822 os.chdir(discoveryStart)
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
823 discover = False
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
824 else:
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
825 failed = []
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
826 if discover:
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
827 if testCases:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
828 test = testLoader.loadTestsFromNames(testCases)
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
829 else:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
830 test = testLoader.discover(discoveryStart)
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
831 else:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
832 if testFileName:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
833 module = __import__(self.testName)
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
834 else:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
835 module = None
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
836 if failedOnly and self.__failedTests:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
837 if module:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
838 failed = [t.split(".", 1)[1]
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
839 for t in self.__failedTests]
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
840 else:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
841 failed = self.__failedTests[:]
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
842 test = testLoader.loadTestsFromNames(
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
843 failed, module)
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
844 else:
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
845 test = testLoader.loadTestsFromName(
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
846 testName, module)
4563
881340f4bd0c Fixed a few coding style issue related to 'blind except:' statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4489
diff changeset
847 except Exception:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
848 exc_type, exc_value, exc_tb = sys.exc_info()
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
849 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
850 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
851 self.tr("Unittest"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
852 self.tr(
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
853 "<p>Unable to run test <b>{0}</b>.</p>"
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
854 "<p>{1}<br/>{2}</p>")
3038
7fe9a53280bd Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
855 .format(self.testName, str(exc_type),
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
856 str(exc_value).replace("\n", "<br/>"))
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
857 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
858 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
859
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
860 # now set up the coverage stuff
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
861 if self.coverageCheckBox.isChecked():
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
862 if discover:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
863 covname = os.path.join(discoveryStart, "unittest")
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
864 elif testFileName:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
865 covname = os.path.splitext(
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
866 os.path.abspath(testFileName))[0]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
867 else:
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
868 covname = "unittest"
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
869
6027
d056a536670e Fixed a nasty bug in the unit test dialog when combining unit test with coverage testing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5603
diff changeset
870 from DebugClients.Python.coverage import coverage
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
871 cover = coverage(data_file="{0}.coverage".format(covname))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
872 if self.coverageEraseCheckBox.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
873 cover.erase()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
874 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
875 cover = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
876
6904
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6902
diff changeset
877 self.testResult = QtTestResult(
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6902
diff changeset
878 self, self.failfastCheckBox.isChecked())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
879 self.totalTests = test.countTestCases()
1499
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
880 self.__failedTests = []
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
881 self.__setRunningMode()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
882 if cover:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
883 cover.start()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
884 test.run(self.testResult)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
885 if cover:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
886 cover.stop()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
887 cover.save()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
888 self.__setStoppedMode()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
889 sys.path = self.savedSysPath
6893
d29a7b8fab0f UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
890
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
891 def __UTPrepared(self, nrTests, exc_type, exc_value):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
892 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
893 Private slot to handle the utPrepared signal.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
894
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
895 If the unittest suite was loaded successfully, we ask the
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
896 client to run the test suite.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
897
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
898 @param nrTests number of tests contained in the test suite (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
899 @param exc_type type of exception occured during preparation (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
900 @param exc_value value of exception occured during preparation (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
901 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
902 if nrTests == 0:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
903 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
904 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
905 self.tr("Unittest"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
906 self.tr(
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
907 "<p>Unable to run test <b>{0}</b>.</p>"
6902
67d0ad66b59a Updated translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
908 "<p>{1}<br/>{2}</p>")
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
909 .format(self.testName, exc_type,
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
910 exc_value.replace("\n", "<br/>"))
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
911 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
912 return
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
913
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
914 self.totalTests = nrTests
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
915 self.__setRunningMode()
6904
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6902
diff changeset
916 self.__dbs.remoteUTRun(debug=self.debuggerCheckBox.isChecked(),
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6902
diff changeset
917 failfast=self.failfastCheckBox.isChecked())
6893
d29a7b8fab0f UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
918
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
919 @pyqtSlot()
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
920 def __stopTests(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
921 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
922 Private slot to stop the test.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
923 """
6892
c147620313c5 UnittestDialog: fixed an issue running tests for a project and removed the (obsolete) 'local' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6890
diff changeset
924 if self.__dbs:
6888
e5f03f779b00 Unit Test: added the capability to select the virtual environment for the unittest run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
925 self.__dbs.remoteUTStop()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
926 elif self.testResult:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
927 self.testResult.stop()
6893
d29a7b8fab0f UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
928
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
929 def on_errorsListWidget_currentTextChanged(self, text):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
930 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
931 Private slot to handle the highlighted signal.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
932
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2681
diff changeset
933 @param text current text (string)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
934 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
935 if text:
1166
a94b0a2fafd7 Extended the unit test interface to support skipped tests, expected failures and unexpected successes and to better cope with Python2 scripts when run from the eric IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
936 for pattern in self.rxPatterns:
a94b0a2fafd7 Extended the unit test interface to support skipped tests, expected failures and unexpected successes and to better cope with Python2 scripts when run from the eric IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
937 text = re.sub(pattern, "", text)
5409
c6f4a6f0d051 Fixed a situation in the unittest dialog where translations are only partially done.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
938
c6f4a6f0d051 Fixed a situation in the unittest dialog where translations are only partially done.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
939 foundItems = self.testsListWidget.findItems(
c6f4a6f0d051 Fixed a situation in the unittest dialog where translations are only partially done.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
940 text, Qt.MatchFlags(Qt.MatchExactly))
c6f4a6f0d051 Fixed a situation in the unittest dialog where translations are only partially done.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
941 if len(foundItems) > 0:
c6f4a6f0d051 Fixed a situation in the unittest dialog where translations are only partially done.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
942 itm = foundItems[0]
c6f4a6f0d051 Fixed a situation in the unittest dialog where translations are only partially done.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
943 self.testsListWidget.setCurrentItem(itm)
c6f4a6f0d051 Fixed a situation in the unittest dialog where translations are only partially done.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
944 self.testsListWidget.scrollToItem(itm)
6893
d29a7b8fab0f UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
945
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
946 def __setRunningMode(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
947 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
948 Private method to set the GUI in running mode.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
949 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
950 self.running = True
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
951 self.tabWidget.setCurrentIndex(1)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
952
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
953 # reset counters and error infos
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
954 self.runCount = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
955 self.failCount = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
956 self.errorCount = 0
1166
a94b0a2fafd7 Extended the unit test interface to support skipped tests, expected failures and unexpected successes and to better cope with Python2 scripts when run from the eric IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
957 self.skippedCount = 0
a94b0a2fafd7 Extended the unit test interface to support skipped tests, expected failures and unexpected successes and to better cope with Python2 scripts when run from the eric IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
958 self.expectedFailureCount = 0
a94b0a2fafd7 Extended the unit test interface to support skipped tests, expected failures and unexpected successes and to better cope with Python2 scripts when run from the eric IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
959 self.unexpectedSuccessCount = 0
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
960 self.remainingCount = self.totalTests
6893
d29a7b8fab0f UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
961
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
962 # reset the GUI
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
963 self.progressCounterRunCount.setText(str(self.runCount))
1166
a94b0a2fafd7 Extended the unit test interface to support skipped tests, expected failures and unexpected successes and to better cope with Python2 scripts when run from the eric IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
964 self.progressCounterRemCount.setText(str(self.remainingCount))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
965 self.progressCounterFailureCount.setText(str(self.failCount))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
966 self.progressCounterErrorCount.setText(str(self.errorCount))
1166
a94b0a2fafd7 Extended the unit test interface to support skipped tests, expected failures and unexpected successes and to better cope with Python2 scripts when run from the eric IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
967 self.progressCounterSkippedCount.setText(str(self.skippedCount))
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
968 self.progressCounterExpectedFailureCount.setText(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
969 str(self.expectedFailureCount))
1166
a94b0a2fafd7 Extended the unit test interface to support skipped tests, expected failures and unexpected successes and to better cope with Python2 scripts when run from the eric IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
970 self.progressCounterUnexpectedSuccessCount.setText(
a94b0a2fafd7 Extended the unit test interface to support skipped tests, expected failures and unexpected successes and to better cope with Python2 scripts when run from the eric IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
971 str(self.unexpectedSuccessCount))
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
972
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
973 self.errorsListWidget.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
974 self.testsListWidget.clear()
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
975
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
976 self.progressProgressBar.setRange(0, self.totalTests)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
977 self.__setProgressColor("green")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
978 self.progressProgressBar.reset()
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
979
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
980 self.stopButton.setEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
981 self.startButton.setEnabled(False)
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
982 self.startFailedButton.setEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
983 self.stopButton.setDefault(True)
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
984
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
985 self.sbLabel.setText(self.tr("Running"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
986 self.progressLed.on()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
987 QApplication.processEvents()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
988
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
989 self.startTime = time.time()
6893
d29a7b8fab0f UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
990
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
991 def __setStoppedMode(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
992 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
993 Private method to set the GUI in stopped mode.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
994 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
995 self.stopTime = time.time()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
996 self.timeTaken = float(self.stopTime - self.startTime)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
997 self.running = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
998
6897
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
999 failedAvailable = bool(self.__failedTests)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1000 self.startButton.setEnabled(True)
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
1001 self.startFailedButton.setEnabled(failedAvailable)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1002 self.stopButton.setEnabled(False)
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
1003 if failedAvailable:
1499
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
1004 self.startFailedButton.setDefault(True)
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
1005 self.startButton.setDefault(False)
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
1006 else:
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
1007 self.startFailedButton.setDefault(False)
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
1008 self.startButton.setDefault(True)
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
1009 self.sbLabel.setText(
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
1010 self.tr("Ran %n test(s) in {0:.3f}s", "", self.runCount)
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
1011 .format(self.timeTaken))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1012 self.progressLed.off()
1499
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
1013
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
1014 self.unittestStopped.emit()
6904
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6902
diff changeset
1015
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6902
diff changeset
1016 self.raise_()
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6902
diff changeset
1017 self.activateWindow()
6893
d29a7b8fab0f UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
1018
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5409
diff changeset
1019 def testFailed(self, test, exc, testId):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1020 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1021 Public method called if a test fails.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1022
1499
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
1023 @param test name of the test (string)
1166
a94b0a2fafd7 Extended the unit test interface to support skipped tests, expected failures and unexpected successes and to better cope with Python2 scripts when run from the eric IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
1024 @param exc string representation of the exception (string)
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5409
diff changeset
1025 @param testId id of the test (string)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1026 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1027 self.failCount += 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1028 self.progressCounterFailureCount.setText(str(self.failCount))
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
1029 itm = QListWidgetItem(self.tr("Failure: {0}").format(test))
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
1030 itm.setData(UnittestDialog.ErrorsInfoRole, (test, exc))
1166
a94b0a2fafd7 Extended the unit test interface to support skipped tests, expected failures and unexpected successes and to better cope with Python2 scripts when run from the eric IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
1031 self.errorsListWidget.insertItem(0, itm)
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5409
diff changeset
1032 self.__failedTests.append(testId)
6893
d29a7b8fab0f UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
1033
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5409
diff changeset
1034 def testErrored(self, test, exc, testId):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1035 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1036 Public method called if a test errors.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1037
1499
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
1038 @param test name of the test (string)
1166
a94b0a2fafd7 Extended the unit test interface to support skipped tests, expected failures and unexpected successes and to better cope with Python2 scripts when run from the eric IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
1039 @param exc string representation of the exception (string)
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5409
diff changeset
1040 @param testId id of the test (string)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1041 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1042 self.errorCount += 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1043 self.progressCounterErrorCount.setText(str(self.errorCount))
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
1044 itm = QListWidgetItem(self.tr("Error: {0}").format(test))
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6905
diff changeset
1045 itm.setData(UnittestDialog.ErrorsInfoRole, (test, exc))
1166
a94b0a2fafd7 Extended the unit test interface to support skipped tests, expected failures and unexpected successes and to better cope with Python2 scripts when run from the eric IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
1046 self.errorsListWidget.insertItem(0, itm)
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5409
diff changeset
1047 self.__failedTests.append(testId)
6893
d29a7b8fab0f UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
1048
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5409
diff changeset
1049 def testSkipped(self, test, reason, testId):
1166
a94b0a2fafd7 Extended the unit test interface to support skipped tests, expected failures and unexpected successes and to better cope with Python2 scripts when run from the eric IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
1050 """
a94b0a2fafd7 Extended the unit test interface to support skipped tests, expected failures and unexpected successes and to better cope with Python2 scripts when run from the eric IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
1051 Public method called if a test was skipped.
a94b0a2fafd7 Extended the unit test interface to support skipped tests, expected failures and unexpected successes and to better cope with Python2 scripts when run from the eric IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
1052
1499
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
1053 @param test name of the test (string)
1166
a94b0a2fafd7 Extended the unit test interface to support skipped tests, expected failures and unexpected successes and to better cope with Python2 scripts when run from the eric IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
1054 @param reason reason for skipping the test (string)