eric6/PyUnit/UnittestDialog.py

Mon, 15 Apr 2019 19:53:29 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 15 Apr 2019 19:53:29 +0200
branch
setup.py
changeset 6949
a5255f1ba3f0
parent 6942
2602857055c5
child 7071
c9ff30a1acbb
permissions
-rw-r--r--

setup.py: continued implementing support for setup.py.

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