def run_all_tests(self): """Callback method to run all the tests found in MAYA_MODULE_PATH.""" self.reset_rollback_importer() test_suite = unittest.TestSuite() mayaunittest.get_tests(test_suite=test_suite) self.output_console.clear() self.model.run_tests(self.output_console, test_suite)
def run_selected_tests(self): """Callback method to run the selected tests in the UI.""" self.reset_rollback_importer() test_suite = unittest.TestSuite() indices = self.test_view.selectedIndexes() if not indices: return # Remove any child nodes if parent nodes are in the list. This will prevent duplicate # tests from being run. paths = [index.internalPointer().path() for index in indices] test_paths = [] for path in paths: tokens = path.split(".") for i in range(len(tokens) - 1): p = ".".join(tokens[0:i + 1]) if p in paths: break else: test_paths.append(path) # Now get the tests with the pruned paths for path in test_paths: mayaunittest.get_tests(test=path, test_suite=test_suite) self.output_console.clear() self.model.run_tests(self.output_console, test_suite)
def run_selected_tests(self): """Callback method to run the selected tests in the UI.""" self.reset_rollback_importer() test_suite = unittest.TestSuite() indices = self.test_view.selectedIndexes() if not indices: return # Remove any child nodes if parent nodes are in the list. This will prevent duplicate tests from being run. paths = [index.internalPointer().path() for index in indices] test_paths = [] for path in paths: tokens = path.split('.') for i in range(len(tokens) - 1): p = '.'.join(tokens[0:i+1]) if p in paths: break else: test_paths.append(path) # Now get the tests with the pruned paths for path in test_paths: mayaunittest.get_tests(test=path, test_suite=test_suite) self.output_console.clear() self.model.run_tests(self.stream, test_suite)
def run_all_tests(self): """Callback method to run all the tests found in MAYA_MODULE_PATH.""" self.reset_rollback_importer() test_suite = unittest.TestSuite() mayaunittest.get_tests(test_suite=test_suite) self.output_console.clear() self.model.run_tests(self.stream, test_suite)
def run_failed_tests(self): """Callback method to run all the tests with fail or error statuses.""" self.reset_rollback_importer() test_suite = unittest.TestSuite() for node in self.model.node_lookup.values(): if isinstance(node.test, unittest.TestCase) and node.get_status() in {TestStatus.fail, TestStatus.error}: mayaunittest.get_tests(test=node.path(), test_suite=test_suite) self.output_console.clear() self.model.run_tests(self.stream, test_suite)
def run_failed_tests(self): """Callback method to run all the tests with fail or error statuses.""" self.reset_rollback_importer() test_suite = unittest.TestSuite() for node in self.model.node_lookup.values(): if isinstance(node.test, unittest.TestCase) and node.get_status() in {TestStatus.fail, TestStatus.error}: mayaunittest.get_tests(test=node.path(), test_suite=test_suite) self.output_console.clear() self.model.run_tests(self.stream, test_suite)
def refresh_tests(self): self.reset_rollback_importer() test_suite = mayaunittest.get_tests() root_node = TestNode(test_suite) self.model = TestTreeModel(root_node, self) self.test_view.setModel(self.model) self.expand_tree(root_node)
def __init__(self, *args, **kwargs): super(MayaTestRunnerDialog, self).__init__(*args, **kwargs) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setWindowTitle('CMT Unit Test Runner') self.resize(1000, 600) self.rollback_importer = RollbackImporter() menubar = self.menuBar() menu = menubar.addMenu('Settings') action = menu.addAction('Buffer Output') action.setToolTip('Only display output during a failed test.') action.setCheckable(True) action.setChecked(mayaunittest.Settings.buffer_output) action.toggled.connect(mayaunittest.set_buffer_output) action = menu.addAction('New Scene Between Test') action.setToolTip('Creates a new scene file after each test.') action.setCheckable(True) action.setChecked(mayaunittest.Settings.file_new) action.toggled.connect(mayaunittest.set_file_new) menu = menubar.addMenu('Help') action = menu.addAction('Documentation') action.triggered.connect(documentation) toolbar = self.addToolBar('Tools') action = toolbar.addAction('Run All Tests') action.setIcon(QtGui.QIcon(QtGui.QPixmap(os.path.join(ICON_DIR, 'cmt_run_all_tests.png')))) action.triggered.connect(self.run_all_tests) action.setToolTip('Run all tests.') action = toolbar.addAction('Run Selected Tests') action.setIcon(QtGui.QIcon(QtGui.QPixmap(os.path.join(ICON_DIR, 'cmt_run_selected_tests.png')))) action.setToolTip('Run all selected tests.') action.triggered.connect(self.run_selected_tests) action = toolbar.addAction('Run Failed Tests') action.setIcon(QtGui.QIcon(QtGui.QPixmap(os.path.join(ICON_DIR, 'cmt_run_failed_tests.png')))) action.setToolTip('Run all failed tests.') action.triggered.connect(self.run_failed_tests) widget = QtGui.QWidget() self.setCentralWidget(widget) vbox = QtGui.QVBoxLayout(widget) splitter = QtGui.QSplitter(orientation=QtCore.Qt.Horizontal) self.test_view = QtGui.QTreeView() self.test_view.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) splitter.addWidget(self.test_view) self.output_console = QtGui.QTextEdit() self.output_console.setReadOnly(True) splitter.addWidget(self.output_console) vbox.addWidget(splitter) splitter.setStretchFactor(1, 4) self.stream = TestCaptureStream(self.output_console) test_suite = mayaunittest.get_tests() root_node = TestNode(test_suite) self.model = TestTreeModel(root_node, self) self.test_view.setModel(self.model) self.expand_tree(root_node)
def __init__(self, *args, **kwargs): super(MayaTestRunnerDialog, self).__init__(*args, **kwargs) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setWindowTitle('CMT Unit Test Runner') self.resize(1000, 600) self.rollback_importer = RollbackImporter() menubar = self.menuBar() menu = menubar.addMenu('Settings') action = menu.addAction('Buffer Output') action.setToolTip('Only display output during a failed test.') action.setCheckable(True) action.setChecked(mayaunittest.Settings.buffer_output) action.toggled.connect(mayaunittest.set_buffer_output) action = menu.addAction('New Scene Between Test') action.setToolTip('Creates a new scene file after each test.') action.setCheckable(True) action.setChecked(mayaunittest.Settings.file_new) action.toggled.connect(mayaunittest.set_file_new) menu = menubar.addMenu('Help') action = menu.addAction('Documentation') action.triggered.connect(documentation) toolbar = self.addToolBar('Tools') action = toolbar.addAction('Run All Tests') action.setIcon(QtGui.QIcon(QtGui.QPixmap(os.path.join(ICON_DIR, 'cmt_run_all_tests.png')))) action.triggered.connect(self.run_all_tests) action.setToolTip('Run all tests.') action = toolbar.addAction('Run Selected Tests') action.setIcon(QtGui.QIcon(QtGui.QPixmap(os.path.join(ICON_DIR, 'cmt_run_selected_tests.png')))) action.setToolTip('Run all selected tests.') action.triggered.connect(self.run_selected_tests) action = toolbar.addAction('Run Failed Tests') action.setIcon(QtGui.QIcon(QtGui.QPixmap(os.path.join(ICON_DIR, 'cmt_run_failed_tests.png')))) action.setToolTip('Run all failed tests.') action.triggered.connect(self.run_failed_tests) widget = QtWidgets.QWidget() self.setCentralWidget(widget) vbox = QtWidgets.QVBoxLayout(widget) splitter = QtWidgets.QSplitter(orientation=QtCore.Qt.Horizontal) self.test_view = QtWidgets.QTreeView() self.test_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) splitter.addWidget(self.test_view) self.output_console = QtWidgets.QTextEdit() self.output_console.setReadOnly(True) splitter.addWidget(self.output_console) vbox.addWidget(splitter) splitter.setStretchFactor(1, 4) self.stream = TestCaptureStream(self.output_console) test_suite = mayaunittest.get_tests() root_node = TestNode(test_suite) self.model = TestTreeModel(root_node, self) self.test_view.setModel(self.model) self.expand_tree(root_node)