eric6/PyUnit/UnittestDialog.py

Tue, 02 Mar 2021 17:17:09 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 02 Mar 2021 17:17:09 +0100
changeset 8143
2c730d5fd177
parent 8029
5feb4f723f07
child 8149
3fefc0c430f2
permissions
-rw-r--r--

Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.

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