src/eric7/Testing/TestResultsTree.py

branch
eric7-maintenance
changeset 11019
27cd57e98461
parent 10694
f46c1e224e8a
parent 11000
f8371a2dd08f
child 11118
967a88a16a21
diff -r c8df46dd566d -r 27cd57e98461 src/eric7/Testing/TestResultsTree.py
--- a/src/eric7/Testing/TestResultsTree.py	Thu Oct 03 17:06:51 2024 +0200
+++ b/src/eric7/Testing/TestResultsTree.py	Thu Oct 31 10:54:33 2024 +0100
@@ -87,7 +87,7 @@
         self.__testResults = []
         self.__testResultsById = {}
 
-    def index(self, row, column, parent=QModelIndex()):
+    def index(self, row, column, parent=None):
         """
         Public method to generate an index for the given row and column to
         identify the item.
@@ -96,11 +96,14 @@
         @type int
         @param column column for the index
         @type int
-        @param parent index of the parent item (defaults to QModelIndex())
+        @param parent index of the parent item (defaults to None)
         @type QModelIndex (optional)
         @return index for the item
         @rtype QModelIndex
         """
+        if parent is None:
+            parent = QModelIndex()
+
         if not self.hasIndex(row, column, parent):  # check bounds etc.
             return QModelIndex()
 
@@ -211,16 +214,16 @@
         else:
             return self.index(idx, 0)
 
-    def rowCount(self, parent=QModelIndex()):
+    def rowCount(self, parent=None):
         """
         Public method to get the number of row for a given parent index.
 
-        @param parent index of the parent item (defaults to QModelIndex())
+        @param parent index of the parent item (defaults to None)
         @type QModelIndex (optional)
         @return number of rows
         @rtype int
         """
-        if not parent.isValid():
+        if parent is None or not parent.isValid():
             return len(self.__testResults)
 
         if (
@@ -232,16 +235,16 @@
 
         return 0
 
-    def columnCount(self, parent=QModelIndex()):
+    def columnCount(self, parent=None):
         """
         Public method to get the number of columns.
 
-        @param parent index of the parent item (defaults to QModelIndex())
+        @param parent index of the parent item (defaults to None)
         @type QModelIndex (optional)
         @return number of columns
         @rtype int
         """
-        if not parent.isValid():
+        if parent is None or not parent.isValid():
             return len(TestResultsModel.Headers)
         else:
             return 1
@@ -541,7 +544,7 @@
 
         self.spanFirstColumn(startRow, endRow)
 
-    def dataChanged(self, topLeft, bottomRight, roles=[]):
+    def dataChanged(self, topLeft, bottomRight, roles=None):
         """
         Public method called when the model data has changed.
 
@@ -549,9 +552,12 @@
         @type QModelIndex
         @param bottomRight index of the bottom right element
         @type QModelIndex
-        @param roles list of roles changed (defaults to [])
+        @param roles list of roles changed (defaults to None)
         @type list of Qt.ItemDataRole (optional)
         """
+        if roles is None:
+            roles = []
+
         super().dataChanged(topLeft, bottomRight, roles)
 
         while topLeft.parent().isValid():

eric ide

mercurial