eric6/PyUnit/UnittestDialog.py

Sat, 19 Dec 2020 15:22:26 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 19 Dec 2020 15:22:26 +0100
changeset 7900
72b88fb20261
parent 7780
41420f82c0ac
child 7923
91e843545d9a
permissions
-rw-r--r--

Corrected the use of '@keyparam' in the source documentation.

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
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7259
diff changeset
3 # Copyright (c) 2002 - 2020 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
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
51 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
52 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 @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
56 @type str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 @param dbs reference to the debug server object. It is an indication
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 whether we were called from within the eric6 IDE.
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
59 @type DebugServer
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 @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
61 @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
62 @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
63 @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
64 @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
65 @type str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 """
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
67 super(UnittestDialog, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 if name:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.setObjectName(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 self.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71
4582
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
72 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
73 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
74 self.testsuitePicker.setSizeAdjustPolicy(
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4582
diff changeset
75 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
76
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
77 self.discoveryPicker.setMode(E5PathPickerModes.DirectoryMode)
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
78 self.discoveryPicker.setInsertPolicy(QComboBox.InsertAtTop)
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
79 self.discoveryPicker.setSizeAdjustPolicy(
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
80 QComboBox.AdjustToMinimumContentsLength)
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
81
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
82 self.discoverButton = self.buttonBox.addButton(
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
83 self.tr("Discover"), QDialogButtonBox.ActionRole)
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
84 self.discoverButton.setToolTip(self.tr(
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
85 "Discover tests"))
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
86 self.discoverButton.setWhatsThis(self.tr(
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
87 """<b>Discover</b>"""
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
88 """<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
89 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
90 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
91 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
92 "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
93 self.startButton.setWhatsThis(self.tr(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 """<b>Start Test</b>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 """<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
96 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
97 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
98 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
99 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
100 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
101 """<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
102 """<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
103 """ testsuite.</p>"""))
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
104 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
105 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
106 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
107 self.stopButton.setWhatsThis(self.tr(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 """<b>Stop Test</b>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 """<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
110 self.discoverButton.setEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 self.stopButton.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 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
113 self.startFailedButton.setEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114
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
115 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
116 self.__forProject = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
118 self.setWindowFlags(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
119 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
120 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
121 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
122 self.setWindowTitle(self.tr("Unittest"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 if dbs:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 self.ui = ui
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
125
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
126 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
127
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
128 # 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
129 # variant
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
130 self.__venvManager = e5App().getObject("VirtualEnvManager")
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
131 self.__populateVenvComboBox()
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
132 self.__venvManager.virtualEnvironmentAdded.connect(
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
133 self.__populateVenvComboBox)
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
134 self.__venvManager.virtualEnvironmentRemoved.connect(
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
135 self.__populateVenvComboBox)
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
136 self.__venvManager.virtualEnvironmentChanged.connect(
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
137 self.__populateVenvComboBox)
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
138 else:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
139 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
140 self.debuggerCheckBox.setVisible(False)
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
141 self.venvComboBox.setVisible(bool(self.__venvManager))
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
142 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
143
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 self.__setProgressColor("green")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 self.progressLed.setDarkFactor(150)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 self.progressLed.off()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
148 self.discoverHistory = []
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 self.fileHistory = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 self.testNameHistory = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 self.running = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 self.savedModulelist = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 self.savedSysPath = sys.path
6897
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
154 self.savedCwd = os.getcwd()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 if prog:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 self.insertProg(prog)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157
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
158 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
159 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
160 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
161 # 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
162 "^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
163 "^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
164 ]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165
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
166 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
167
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
168 # now connect the debug server signals if called from the eric6 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
169 if self.__dbs:
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
170 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
171 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
172 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
173 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
174 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
175 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
176 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
177 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
178 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
179 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
180 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
181
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
182 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
183
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
184 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
185 """
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
186 Protected slot to handle key press events.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187
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
188 @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
189 """
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
190 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
191 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
192
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
193 def __populateVenvComboBox(self):
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
194 """
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
195 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
196 """
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
197 currentText = self.venvComboBox.currentText()
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
198 self.venvComboBox.clear()
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
199 self.venvComboBox.addItem("")
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
200 self.venvComboBox.addItems(
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
201 sorted(self.__venvManager.getVirtualenvNames()))
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
202 index = self.venvComboBox.findText(currentText)
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
203 if index < 0:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
204 index = 0
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
205 self.venvComboBox.setCurrentIndex(index)
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
206
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 def __setProgressColor(self, color):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 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
210
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 @param color colour to be shown (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 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
214
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
215 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
216 """
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
217 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
218
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
219 @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
220 @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
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 self.__forProject = forProject
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
223 if forProject:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
224 project = e5App().getObject("Project")
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
225 if project.isOpen():
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
226 self.insertDiscovery(project.getProjectPath())
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
227 else:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
228 self.insertDiscovery("")
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
229 else:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
230 self.insertDiscovery("")
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
231
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
232 self.discoveryList.clear()
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
233 self.tabWidget.setCurrentIndex(0)
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
234
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
235 def insertDiscovery(self, start):
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
236 """
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
237 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
238 discoveryPicker object.
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
239
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
240 @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
241 @type str
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
242 """
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
243 # 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
244 if start is None:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
245 start = ""
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
246 if start in self.discoverHistory:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
247 self.discoverHistory.remove(start)
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
248 self.discoverHistory.insert(0, start)
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
249 self.discoveryPicker.clear()
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
250 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
251
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 def insertProg(self, prog):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 """
4582
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
254 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
255 object.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 @param prog filename to be inserted (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 """
4582
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
259 # prepend the selected file to the testsuite picker
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 if prog is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 prog = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 if prog in self.fileHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 self.fileHistory.remove(prog)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 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
265 self.testsuitePicker.clear()
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
266 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
267
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 def insertTestName(self, testName):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 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
271
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 @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
273 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 # prepend the selected file to the testsuite combobox
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 if testName is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 testName = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 if testName in self.testNameHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 self.testNameHistory.remove(testName)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 self.testNameHistory.insert(0, testName)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 self.testComboBox.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 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
282
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 @pyqtSlot()
4582
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
284 def on_testsuitePicker_aboutToShowPathPickerDialog(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 """
4582
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
286 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
287 """
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
288 if self.__dbs:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
289 py3Extensions = ' '.join(
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
290 ["*{0}".format(ext)
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
291 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
292 )
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5409
diff changeset
293 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
294 "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
295 ).format(py3Extensions)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 else:
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5409
diff changeset
297 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
298 self.testsuitePicker.setFilters(fileFilter)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299
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
300 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
301 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
302 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
303 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
304 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
305 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
306 defaultDirectory = project.getProjectPath()
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
307 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
308
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 @pyqtSlot(str)
4582
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
310 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
311 """
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
312 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
313
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
314 @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
315 @type str
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
316 """
3a1d1d4c6f4f Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4563
diff changeset
317 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
318
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
319 @pyqtSlot(str)
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
320 def on_testsuitePicker_editTextChanged(self, path):
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
321 """
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
322 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
323
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
324 @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
325 @type str
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
326 """
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
327 self.startFailedButton.setEnabled(False)
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 @pyqtSlot(bool)
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
330 def on_discoverCheckBox_toggled(self, checked):
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
331 """
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
332 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
333
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
334 @param checked state of the checkbox
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
335 @type bool
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
336 """
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
337 self.discoverButton.setEnabled(checked)
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
338 self.discoveryList.clear()
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
339
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
340 if not bool(self.discoveryPicker.currentText()):
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
341 if self.__forProject:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
342 project = e5App().getObject("Project")
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
343 if project.isOpen():
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
344 self.insertDiscovery(project.getProjectPath())
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
345 return
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
346
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
347 self.insertDiscovery(Preferences.getMultiProject("Workspace"))
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
348
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 def on_buttonBox_clicked(self, button):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 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
352
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 @param button button that was clicked (QAbstractButton)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 """
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
355 if button == self.discoverButton:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
356 self.__discover()
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
357 elif button == self.startButton:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
358 self.startTests()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 elif button == self.stopButton:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
360 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
361 elif button == self.startFailedButton:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
362 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
363
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 @pyqtSlot()
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
365 def __discover(self):
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
366 """
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
367 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
368 """
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
369 if self.running:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
370 return
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
371
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
372 self.discoveryList.clear()
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 discoveryStart = self.discoveryPicker.currentText()
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
375 self.sbLabel.setText(self.tr("Discovering Tests"))
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
376 QApplication.processEvents()
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
377
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
378 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
379 if self.__dbs:
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
380 venvName = self.venvComboBox.currentText()
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
381
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
382 # we are cooperating with the eric6 IDE
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
383 project = e5App().getObject("Project")
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
384 if self.__forProject:
7072
66ef92f769bf Allow unittest for projects without main script.
Mikhail Terekhov
parents: 7071
diff changeset
385 mainScript = project.getMainScript(True)
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
386 clientType = project.getProjectLanguage()
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
387 if mainScript:
7072
66ef92f769bf Allow unittest for projects without main script.
Mikhail Terekhov
parents: 7071
diff changeset
388 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
389 else:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
390 workdir = project.getProjectPath()
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
391 sysPath = [workdir]
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
392 if not discoveryStart:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
393 discoveryStart = workdir
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
394 else:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
395 if not discoveryStart:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
396 E5MessageBox.critical(
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
397 self,
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
398 self.tr("Unittest"),
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
399 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
400 " auto-discovery."))
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
401 return
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
402
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
403 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
404 clientType = "Python3"
6905
889339ffe6cf UnittestDialog: fixed an issue causing an uncaught exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6904
diff changeset
405 sysPath = []
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
406 self.__dbs.remoteUTDiscover(clientType, self.__forProject,
7071
c9ff30a1acbb Fix unittest discovery, allow discovery start in project subdirectory.
Mikhail Terekhov
parents: 6942
diff changeset
407 venvName, sysPath, workdir,
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
408 discoveryStart)
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
409 else:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
410 # we are running as an application
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
411 if not discoveryStart:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
412 E5MessageBox.critical(
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
413 self,
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
414 self.tr("Unittest"),
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
415 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
416 " auto-discovery."))
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
417 return
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
418
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
419 if discoveryStart:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
420 sys.path = (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
421 [os.path.abspath(discoveryStart)] +
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
422 self.savedSysPath
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
423 )
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
424
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
425 # 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
426 # running the test
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
427 if self.savedModulelist:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
428 for modname in list(sys.modules.keys()):
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
429 if modname not in self.savedModulelist:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
430 # delete it
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
431 del(sys.modules[modname])
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
432 self.savedModulelist = sys.modules.copy()
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
433
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
434 # now try to discover the testsuite
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
435 os.chdir(discoveryStart)
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
436 try:
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
437 testLoader = unittest.TestLoader()
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
438 test = testLoader.discover(discoveryStart)
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
439 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
440 E5MessageBox.critical(
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
441 self,
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
442 self.tr("Unittest"),
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
443 self.tr(
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
444 "<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
445 "<p>{0}</p>"
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
446 ).format("<br/>".join(testLoader.errors)
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
447 .replace("\n", "<br/>"))
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
448 )
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
449 self.sbLabel.clear()
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
450 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
451 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
452 test, discoveryStart)
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
453 self.__populateDiscoveryResults(testsList)
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
454 self.sbLabel.setText(
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
455 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
456 len(testsList)))
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
457 self.tabWidget.setCurrentIndex(0)
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
458 except Exception:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
459 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
460 E5MessageBox.critical(
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
461 self,
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
462 self.tr("Unittest"),
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
463 self.tr(
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
464 "<p>Unable to discover tests.</p>"
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
465 "<p>{0}<br/>{1}</p>")
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
466 .format(str(exc_type),
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
467 str(exc_value).replace("\n", "<br/>"))
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
468 )
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
469 self.sbLabel.clear()
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
470
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
471 sys.path = self.savedSysPath
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
472
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
473 def __assembleTestCasesList(self, suite, start):
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
474 """
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
475 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
476 suite.
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
477
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
478 @param suite test suite to be inspected
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
479 @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
480 @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
481 @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
482 @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
483 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
484 @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
485 """
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
486 testCases = []
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
487 for test in suite:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
488 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
489 testCases.extend(self.__assembleTestCasesList(test, start))
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
490 else:
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
491 testId = test.id()
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
492 if (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
493 "ModuleImportFailure" not in testId and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
494 "LoadTestsFailure" not in testId and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
495 "_FailedTest" not in testId
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
496 ):
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
497 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
498 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
499 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
500 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
501 (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
502 )
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
503 return testCases
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
504
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
505 def __findDiscoveryItem(self, modulePath):
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
506 """
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
507 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
508
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
509 @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
510 @type str
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
511 @return reference to the item or None
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
512 @rtype QTreeWidgetItem or None
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 itm = self.discoveryList.topLevelItem(0)
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
515 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
516 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
517 return itm
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
518 itm = self.discoveryList.itemBelow(itm)
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
519
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
520 return None
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
521
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
522 def __populateDiscoveryResults(self, tests):
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
523 """
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
524 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
525
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
526 @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
527 @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
528 """
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
529 for test, _testDescription, filename in tests:
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
530 testPath = test.split(".")
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
531 pitm = None
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
532 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
533 modulePath = ".".join(testPath[:index])
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
534 itm = self.__findDiscoveryItem(modulePath)
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
535 if itm is not None:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
536 pitm = itm
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
537 else:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
538 if pitm is None:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
539 itm = QTreeWidgetItem(self.discoveryList,
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
540 [testPath[index - 1]])
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
541 else:
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
542 itm = QTreeWidgetItem(pitm,
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
543 [testPath[index - 1]])
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
544 pitm.setExpanded(True)
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
545 itm.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
546 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
547 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
548 if (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
549 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
550 itm.text(0)
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
551 ):
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
552 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
553 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
554 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
555 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
556 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
557 itm.setData(0, UnittestDialog.TestCaseFileRole, fn)
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
558 pitm = itm
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
559
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
560 def __selectedTestCases(self, parent=None):
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
561 """
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
562 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
563
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
564 @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
565 @type QTreeWidgetItem
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
566 @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
567 @rtype list of str
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 selectedTests = []
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
570 if parent is None:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
571 # top level
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
572 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
573 itm = self.discoveryList.topLevelItem(index)
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
574 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
575 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
576 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
577 # 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
578 elif itm.childCount():
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
579 # recursively check children
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
580 selectedTests.extend(self.__selectedTestCases(itm))
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
581
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
582 else:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
583 # parent item with children
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
584 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
585 itm = parent.child(index)
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
586 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
587 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
588 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
589 # 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
590 elif itm.childCount():
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
591 # recursively check children
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
592 selectedTests.extend(self.__selectedTestCases(itm))
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
593
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
594 return selectedTests
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
595
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
596 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
597 """
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
598 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
599
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
600 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
601 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
602
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
603 @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
604 @type str
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
605 @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
606 @type str
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
607 @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
608 @type str
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 if testCases:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
611 self.__populateDiscoveryResults(testCases)
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
612 self.sbLabel.setText(
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
613 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
614 len(testCases)))
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
615 self.tabWidget.setCurrentIndex(0)
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
616 else:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
617 E5MessageBox.critical(
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
618 self,
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
619 self.tr("Unittest"),
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
620 self.tr("<p>Unable to discover tests.</p>"
6902
67d0ad66b59a Updated translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
621 "<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
622 .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
623 )
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
624
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
625 @pyqtSlot(QTreeWidgetItem, int)
7073
e86027967f5c Recursively change children's check state when an item check state is changed
Mikhail Terekhov
parents: 7072
diff changeset
626 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
627 """
e86027967f5c Recursively change children's check state when an item check state is changed
Mikhail Terekhov
parents: 7072
diff changeset
628 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
629
e86027967f5c Recursively change children's check state when an item check state is changed
Mikhail Terekhov
parents: 7072
diff changeset
630 @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
631 @type QTreeWidgetItem
e86027967f5c Recursively change children's check state when an item check state is changed
Mikhail Terekhov
parents: 7072
diff changeset
632 @param column changed column
e86027967f5c Recursively change children's check state when an item check state is changed
Mikhail Terekhov
parents: 7072
diff changeset
633 @type int
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 if column == 0:
e86027967f5c Recursively change children's check state when an item check state is changed
Mikhail Terekhov
parents: 7072
diff changeset
636 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
637 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
638
e86027967f5c Recursively change children's check state when an item check state is changed
Mikhail Terekhov
parents: 7072
diff changeset
639 @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
640 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
641 """
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
642 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
643
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
644 @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
645 @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
646 @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
647 @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
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 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
650 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
651 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
652 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
653 # 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
654 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
655 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
656 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
657
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
658 @pyqtSlot()
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
659 def startTests(self, failedOnly=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
660 """
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
661 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
662
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
663 @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
664 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
665 if self.running:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
666 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
667
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
668 discover = self.discoverCheckBox.isChecked()
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
669 if discover:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
670 discoveryStart = self.discoveryPicker.currentText()
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
671 testFileName = ""
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
672 testName = ""
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
673 else:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
674 discoveryStart = ""
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
675 testFileName = self.testsuitePicker.currentText()
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
676 testName = self.testComboBox.currentText()
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
677 if testName:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
678 self.insertTestName(testName)
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
679 if testFileName and not testName:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
680 testName = "suite"
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
681
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
682 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
683 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
684 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
685 self.tr("Unittest"),
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
686 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
687 " file or a dotted test name."))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
688 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
689
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
690 # 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
691 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
692 self.sbLabel.setText(self.tr("Preparing Testsuite"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
693 QApplication.processEvents()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
694
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
695 if discover:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
696 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
697 else:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
698 # 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
699 if testFileName:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
700 self.testName = os.path.splitext(
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
701 os.path.basename(testFileName))[0]
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
702 elif testName:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
703 self.testName = testName
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
704 else:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
705 self.testName = self.tr("<Unnamed Test>")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
706
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
707 if failedOnly:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
708 testCases = []
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
709 else:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
710 testCases = self.__selectedTestCases()
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
711
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
712 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
713 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
714 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
715 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
716 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
717 """ 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
718 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
719 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
720
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
721 if self.__dbs:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
722 venvName = self.venvComboBox.currentText()
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
723
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
724 # we are cooperating with the eric6 IDE
53
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 34
diff changeset
725 project = e5App().getObject("Project")
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
726 if self.__forProject:
7072
66ef92f769bf Allow unittest for projects without main script.
Mikhail Terekhov
parents: 7071
diff changeset
727 mainScript = project.getMainScript(True)
1782
90bd49fec9ff Fixed an issue in the unit test dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
728 clientType = project.getProjectLanguage()
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
729 if mainScript:
7072
66ef92f769bf Allow unittest for projects without main script.
Mikhail Terekhov
parents: 7071
diff changeset
730 workdir = os.path.dirname(os.path.abspath(mainScript))
66ef92f769bf Allow unittest for projects without main script.
Mikhail Terekhov
parents: 7071
diff changeset
731 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
732 else:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
733 workdir = project.getProjectPath()
7072
66ef92f769bf Allow unittest for projects without main script.
Mikhail Terekhov
parents: 7071
diff changeset
734 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
735 sysPath = [workdir]
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
736 if discover and not discoveryStart:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
737 discoveryStart = workdir
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
738 else:
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
739 if discover:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
740 if not discoveryStart:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
741 E5MessageBox.critical(
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
742 self,
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
743 self.tr("Unittest"),
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
744 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
745 " auto-discovery."))
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
746 return
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
747
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
748 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
749 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
750 clientType = "Python3"
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
751 elif testFileName:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
752 mainScript = os.path.abspath(testFileName)
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
753 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
754 clientType = "Python3"
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
755 coverageFile = os.path.splitext(mainScript)[0]
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
756 else:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
757 coverageFile = os.path.abspath("unittest")
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
758 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
759 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
760 sysPath = []
6897
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
761 if failedOnly and self.__failedTests:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
762 failed = self.__failedTests[:]
6897
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
763 if discover:
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
764 workdir = discoveryStart
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
765 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
766 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
767 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
768 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
769 self.__dbs.remoteUTPrepare(
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
770 testFileName, self.testName, testName, failed,
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
771 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
772 self.coverageEraseCheckBox.isChecked(), clientType=clientType,
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
773 forProject=self.__forProject, workdir=workdir,
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
774 venvName=venvName, syspath=sysPath,
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
775 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
776 testCases=testCases, debug=self.debuggerCheckBox.isChecked())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
777 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
778 # 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
779 if discover and not discoveryStart:
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
780 E5MessageBox.critical(
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
781 self,
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
782 self.tr("Unittest"),
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
783 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
784 " auto-discovery."))
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
785 return
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
786
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
787 if testFileName:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
788 sys.path = (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
789 [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
790 self.savedSysPath
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
791 )
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
792 elif discoveryStart:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
793 sys.path = (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
794 [os.path.abspath(discoveryStart)] +
6899
8c4cf9c405c7 UnittestDialog: started implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6897
diff changeset
795 self.savedSysPath
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
796 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
797
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
798 # 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
799 # running the test
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
800 if self.savedModulelist:
34
93367928a93b Ported the unittest dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
801 for modname in list(sys.modules.keys()):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
802 if modname not in self.savedModulelist:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
803 # delete it
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
804 del(sys.modules[modname])
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
805 self.savedModulelist = sys.modules.copy()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
806
6897
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
807 os.chdir(self.savedCwd)
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
808
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
809 # now try to generate the testsuite
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
810 try:
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
811 testLoader = unittest.TestLoader()
6897
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
812 if failedOnly and self.__failedTests:
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
813 failed = self.__failedTests[:]
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
814 if discover:
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
815 os.chdir(discoveryStart)
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
816 discover = False
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
817 else:
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
818 failed = []
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
819 if discover:
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
820 if testCases:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
821 test = testLoader.loadTestsFromNames(testCases)
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
822 else:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6900
diff changeset
823 test = testLoader.discover(discoveryStart)
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
824 else:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
825 if testFileName:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
826 module = __import__(self.testName)
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
827 else:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
828 module = None
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
829 if failedOnly and self.__failedTests:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
830 if module:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
831 failed = [t.split(".", 1)[1]
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
832 for t in self.__failedTests]
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
833 else:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
834 failed = self.__failedTests[:]
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
835 test = testLoader.loadTestsFromNames(
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
836 failed, module)
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
837 else:
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
838 test = testLoader.loadTestsFromName(
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
839 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
840 except Exception:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
841 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
842 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
843 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
844 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
845 self.tr(
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
846 "<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
847 "<p>{1}<br/>{2}</p>")
3038
7fe9a53280bd Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
848 .format(self.testName, str(exc_type),
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
849 str(exc_value).replace("\n", "<br/>"))
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
850 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
851 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
852
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
853 # now set up the coverage stuff
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
854 if self.coverageCheckBox.isChecked():
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
855 if discover:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
856 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
857 elif testFileName:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
858 covname = os.path.splitext(
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
859 os.path.abspath(testFileName))[0]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
860 else:
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
861 covname = "unittest"
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
862
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
863 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
864 cover = coverage(data_file="{0}.coverage".format(covname))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
865 if self.coverageEraseCheckBox.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
866 cover.erase()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
867 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
868 cover = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
869
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
870 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
871 self, self.failfastCheckBox.isChecked())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
872 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
873 self.__failedTests = []
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
874 self.__setRunningMode()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
875 if cover:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
876 cover.start()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
877 test.run(self.testResult)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
878 if cover:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
879 cover.stop()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
880 cover.save()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
881 self.__setStoppedMode()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
882 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
883
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
884 def __UTPrepared(self, nrTests, exc_type, exc_value):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
885 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
886 Private slot to handle the utPrepared signal.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
887
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
888 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
889 client to run the test suite.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
890
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
891 @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
892 @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
893 @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
894 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
895 if nrTests == 0:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
896 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
897 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
898 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
899 self.tr(
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
900 "<p>Unable to run test <b>{0}</b>.</p>"
6902
67d0ad66b59a Updated translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
901 "<p>{1}<br/>{2}</p>")
6900
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
902 .format(self.testName, exc_type,
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
903 exc_value.replace("\n", "<br/>"))
060a30488316 UnittestDialog: continued implementing pure discovery support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
904 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
905 return
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
906
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
907 self.totalTests = nrTests
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
908 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
909 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
910 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
911
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
912 @pyqtSlot()
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
913 def __stopTests(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
914 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
915 Private slot to stop the test.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
916 """
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
917 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
918 self.__dbs.remoteUTStop()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
919 elif self.testResult:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
920 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
921
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
922 def on_errorsListWidget_currentTextChanged(self, text):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
923 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
924 Private slot to handle the highlighted signal.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
925
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2681
diff changeset
926 @param text current text (string)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
927 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
928 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
929 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
930 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
931
c6f4a6f0d051 Fixed a situation in the unittest dialog where translations are only partially done.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
932 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
933 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
934 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
935 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
936 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
937 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
938
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
939 def __setRunningMode(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
940 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
941 Private method to set the GUI in running mode.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
942 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
943 self.running = True
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
944 self.tabWidget.setCurrentIndex(1)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
945
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
946 # reset counters and error infos
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
947 self.runCount = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
948 self.failCount = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
949 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
950 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
951 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
952 self.unexpectedSuccessCount = 0
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
953 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
954
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
955 # reset the GUI
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
956 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
957 self.progressCounterRemCount.setText(str(self.remainingCount))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
958 self.progressCounterFailureCount.setText(str(self.failCount))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
959 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
960 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
961 self.progressCounterExpectedFailureCount.setText(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
962 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
963 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
964 str(self.unexpectedSuccessCount))
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
965
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
966 self.errorsListWidget.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
967 self.testsListWidget.clear()
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
968
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
969 self.progressProgressBar.setRange(0, self.totalTests)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
970 self.__setProgressColor("green")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
971 self.progressProgressBar.reset()
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.stopButton.setEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
974 self.startButton.setEnabled(False)
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
975 self.startFailedButton.setEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
976 self.stopButton.setDefault(True)
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
977
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
978 self.sbLabel.setText(self.tr("Running"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
979 self.progressLed.on()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
980 QApplication.processEvents()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
981
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
982 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
983
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
984 def __setStoppedMode(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
985 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
986 Private method to set the GUI in stopped mode.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
987 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
988 self.stopTime = time.time()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
989 self.timeTaken = float(self.stopTime - self.startTime)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
990 self.running = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
991
6897
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
992 failedAvailable = bool(self.__failedTests)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
993 self.startButton.setEnabled(True)
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
994 self.startFailedButton.setEnabled(failedAvailable)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
995 self.stopButton.setEnabled(False)
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
996 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
997 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
998 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
999 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
1000 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
1001 self.startButton.setDefault(True)
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
1002 self.sbLabel.setText(
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6893
diff changeset
1003 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
1004 .format(self.timeTaken))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1005 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
1006
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.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
1008
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
1009 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
1010 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
1011
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5409
diff changeset
1012 def testFailed(self, test, exc, testId):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1013 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1014 Public method called if a test fails.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1015
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
1016 @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
1017 @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
1018 @param testId id of the test (string)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1019 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1020 self.failCount += 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1021 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
1022 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
1023 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
1024 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
1025 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
1026
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5409
diff changeset
1027 def testErrored(self, test, exc, testId):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1028 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1029 Public method called if a test errors.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1030
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
1031 @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
1032 @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
1033 @param testId id of the test (string)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1034 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1035 self.errorCount += 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1036 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
1037 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
1038 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
1039 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
1040 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
1041
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5409
diff changeset
1042 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
1043 """
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
1044 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
1045
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
1046 @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
1047 @param reason reason for skipping the test (string)
5603
4f2dd0850803 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5409
diff changeset
1048 @param testId id 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
1049 """
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 self.skippedCount += 1
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 self.progressCounterSkippedCount.setText(str(self.skippedCount))
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3186
diff changeset
1052 itm = QListWidgetItem(self.tr(" Skipped: {0}").format(reason))
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
1053 itm.setForeground(Qt.blue)
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 c