diff -r 0f579ef4f7ad -r da5ee5012004 ProjectDjango/DjangoTestDataDialog.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ProjectDjango/DjangoTestDataDialog.py Sun Nov 12 14:56:13 2017 +0100 @@ -0,0 +1,87 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2017 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing a dialog to enter some data for running tests. +""" + +from PyQt5.QtWidgets import QDialog + +from .Ui_DjangoTestDataDialog import Ui_DjangoTestDataDialog + + +class DjangoTestDataDialog(QDialog, Ui_DjangoTestDataDialog): + """ + Class implementing a dialog to enter some data for running tests. + """ + def __init__(self, project, parent=None): + """ + Constructor + + @param project reference to the Django project object + @type Project + @param parent reference to the parent widget + @type QWidget + """ + super(DjangoTestDataDialog, self).__init__(parent) + self.setupUi(self) + + self.__project = project + + self.labelsComboBox.addItems( + self.__project.getRecentTestData("RecentTestLabels")) + self.tagsComboBox.addItems( + self.__project.getRecentTestData("RecentTestTags")) + self.excludeTagsComboBox.addItems( + self.__project.getRecentTestData("RecentTestExcludeTags")) + + if self.__project.getDjangoVersion() < (1, 10, 0): + self.tagsComboBox.setEnabled(False) + self.excludeTagsComboBox.setEnabled(False) + + msh = self.minimumSizeHint() + self.resize(max(self.width(), msh.width()), msh.height()) + + def getData(self): + """ + Public method to get the entered data. + + @return tuple containing a list of test labels, a test file pattern, + a list of test tags, a list of test tags to be skipped, a flag + indicating to keep the test database and a flag indicating to run + the tests in reverse order + @rtype tuple of + (list of str, str, list of str, list of str, bool, bool) + """ + labelsStr = self.labelsComboBox.currentText() + if labelsStr: + self.__project.setMostRecentTestData("RecentTestLabels", labelsStr) + labels = labelsStr.split() + else: + labels = [] + + tagsStr = self.labelsComboBox.currentText() + if tagsStr: + self.__project.setMostRecentTestData("RecentTestTags", tagsStr) + tags = tagsStr.split() + else: + tags = [] + + excludeTagsStr = self.labelsComboBox.currentText() + if excludeTagsStr: + self.__project.setMostRecentTestData("RecentTestExcludeTags", + excludeTagsStr) + excludeTags = excludeTagsStr.split() + else: + excludeTags = [] + + return ( + labels, + self.testFilePatternsEdit.text(), + tags, + excludeTags, + self.keepCheckBox.isChecked(), + self.reverseCheckBox.isChecked(), + )