Changeset 65980 in vbox for trunk/src/VBox/ValidationKit/testmanager/core/base.py
- Timestamp:
- Mar 7, 2017 1:00:36 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 113806
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/core/base.py
r65214 r65980 233 233 # Perform deep conversion on ModelDataBase object and lists of them. 234 234 # 235 elif isinstance(oValue, list) and len(oValue) > 0and isinstance(oValue[0], ModelDataBase):235 elif isinstance(oValue, list) and oValue and isinstance(oValue[0], ModelDataBase): 236 236 oValue = copy.copy(oValue); 237 237 for i, _ in enumerate(oValue): … … 269 269 # Perform deep conversion on ModelDataBase object and lists of them. 270 270 # 271 elif isinstance(oValue, list) and len(oValue) > 0and isinstance(oValue[0], ModelDataBase):271 elif isinstance(oValue, list) and oValue and isinstance(oValue[0], ModelDataBase): 272 272 oValue = copy.copy(oValue); 273 273 for i, _ in enumerate(oValue): … … 316 316 lMax = getattr(self, 'klMax_' + sAttr, None)); 317 317 elif sPrefix == 'f': 318 if oValue is ''and not fAllowNull: oValue = '0'; # HACK ALERT! Checkboxes are only added when checked.318 if not oValue and not fAllowNull: oValue = '0'; # HACK ALERT! Checkboxes are only added when checked. 319 319 (oNewValue, sError) = self.validateBool(oValue, aoNilValues = aoNilValues, fAllowNull = fAllowNull); 320 320 elif sPrefix == 'ts': … … 743 743 def validateListOfSomething(asValues, aoNilValues = tuple([[], None]), fAllowNull = True): 744 744 """ Validate a list of some uniform values. Returns a copy of the list (if list it is). """ 745 if asValues in aoNilValues or ( len(asValues) == 0and not fAllowNull):745 if asValues in aoNilValues or (not asValues and not fAllowNull): 746 746 return (asValues, None if fAllowNull else 'Mandatory.') 747 747 … … 750 750 751 751 asValues = list(asValues); # copy the list. 752 if len(asValues) > 0:752 if asValues: 753 753 oType = type(asValues[0]); 754 754 for i in range(1, len(asValues)): … … 764 764 (asValues, sError) = ModelDataBase.validateListOfSomething(asValues, aoNilValues, fAllowNull); 765 765 766 if sError is None and asValues not in aoNilValues and len(asValues) > 0:766 if sError is None and asValues not in aoNilValues and asValues: 767 767 if not utils.isString(asValues[0]): 768 768 return (asValues, 'Invalid item data type.'); … … 793 793 (asValues, sError) = ModelDataBase.validateListOfSomething(asValues, aoNilValues, fAllowNull); 794 794 795 if sError is None and asValues not in aoNilValues and len(asValues) > 0:795 if sError is None and asValues not in aoNilValues and asValues: 796 796 for i, _ in enumerate(asValues): 797 797 sValue = asValues[i]; … … 1089 1089 1090 1090 def testNullConversion(self): 1091 if len(self.aoSamples[0].getDataAttributes()) == 0:1091 if not self.aoSamples[0].getDataAttributes(): 1092 1092 return; 1093 1093 for oSample in self.aoSamples: … … 1261 1261 else: 1262 1262 assert False; 1263 if len(oCriterion.aoSelected) > 0:1263 if oCriterion.aoSelected: 1264 1264 oCriterion.sState = FilterCriterion.ksState_Selected; 1265 1265 else:
Note:
See TracChangeset
for help on using the changeset viewer.