eric6/PyUnit/UnittestDialog.py

Mon, 23 Sep 2019 19:22:12 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 23 Sep 2019 19:22:12 +0200
changeset 7259
7c017076c12e
parent 7229
53054eb5b15a
child 7360
9190402e4505
permissions
-rw-r--r--

Continued to resolve code style issue M841.

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