src/eric7/Testing/TestResultsTree.py

branch
eric7-maintenance
changeset 10079
0222a480e93d
parent 9832
3885b9d7bd31
parent 10069
435cc5875135
child 10460
3b34efa2857c
--- a/src/eric7/Testing/TestResultsTree.py	Tue May 02 10:20:23 2023 +0200
+++ b/src/eric7/Testing/TestResultsTree.py	Sat May 27 19:02:58 2023 +0200
@@ -84,6 +84,7 @@
             }
 
         self.__testResults = []
+        self.__testResultsById = {}
 
     def index(self, row, column, parent=QModelIndex()):
         """
@@ -250,6 +251,7 @@
         """
         self.beginResetModel()
         self.__testResults.clear()
+        self.__testResultsById.clear()
         self.endResetModel()
 
         self.summary.emit("")
@@ -307,6 +309,9 @@
         """
         self.beginResetModel()
         self.__testResults = copy.deepcopy(testResults)
+        self.__testResultsById.clear()
+        for testResult in testResults:
+            self.__testResultsById[testResult.id] = testResult
         self.endResetModel()
 
         self.summary.emit(self.__summary())
@@ -323,6 +328,8 @@
         lastRow = firstRow + len(testResults) - 1
         self.beginInsertRows(QModelIndex(), firstRow, lastRow)
         self.__testResults.extend(testResults)
+        for testResult in testResults:
+            self.__testResultsById[testResult.id] = testResult
         self.endInsertRows()
 
         self.summary.emit(self.__summary())
@@ -340,17 +347,18 @@
         testResultsToBeAdded = []
 
         for testResult in testResults:
-            for index, currentResult in enumerate(self.__testResults):
-                if currentResult.id == testResult.id:
-                    self.__testResults[index] = testResult
-                    if minIndex is None:
-                        minIndex = index
-                        maxIndex = index
-                    else:
-                        minIndex = min(minIndex, index)
-                        maxIndex = max(maxIndex, index)
+            if testResult.id in self.__testResultsById:
+                result = self.__testResultsById[testResult.id]
+                index = self.__testResults.index(result)
+                self.__testResults[index] = testResult
+                self.__testResultsById[testResult.id] = testResult
+                if minIndex is None:
+                    minIndex = index
+                    maxIndex = index
+                else:
+                    minIndex = min(minIndex, index)
+                    maxIndex = max(maxIndex, index)
 
-                    break
             else:
                 # Test result with given id was not found.
                 # Just add it to the list (could be a sub test)
@@ -449,7 +457,7 @@
 
         self.header().sortIndicatorChanged.connect(self.sortByColumn)
         self.header().sortIndicatorChanged.connect(
-            lambda column, order: self.header().setSortIndicatorShown(True)
+            lambda col, order: self.header().setSortIndicatorShown(True)  # noqa: U100
         )
 
     def reset(self):
@@ -474,7 +482,6 @@
         """
         super().rowsInserted(parent, startRow, endRow)
 
-        self.resizeColumns()
         self.spanFirstColumn(startRow, endRow)
 
     def dataChanged(self, topLeft, bottomRight, roles=[]):
@@ -490,7 +497,6 @@
         """
         super().dataChanged(topLeft, bottomRight, roles)
 
-        self.resizeColumns()
         while topLeft.parent().isValid():
             topLeft = topLeft.parent()
         while bottomRight.parent().isValid():

eric ide

mercurial