Exemplo n.º 1
0
 def _test_utility_isConvertableToFloat(self):
     '''
     Tests if convertability to float works
     '''
     assert Utility.isConvertableToFloat("7") == True
     assert Utility.isConvertableToFloat("7.5") == True
     assert Utility.isConvertableToFloat("asdas") == False
     assert Utility.isConvertableToFloat("7.57.5") == False
     assert Utility.isConvertableToFloat([]) == False
     assert Utility.isConvertableToFloat(7) == True
     assert Utility.isConvertableToFloat(7.5) == True
     assert Utility.isConvertableToFloat("7.") == False
Exemplo n.º 2
0
 def setGrade(self, new_gr):
     '''
     Checks if the grade is an integer from 0 to 10 and sets it, otherwise it does nothing
     
     Parameters:
     new_gr - the grade received
     '''
     if (Utility.isInt(new_gr) or Utility.isFloat(new_gr)) and new_gr >= 0 and new_gr <= 10.0:
         self._grade = new_gr
     elif Utility.isConvertableToFloat(new_gr) and float(new_gr) >= 0 and float(new_gr) <= 10.0:
         self._grade = float(new_gr)
     else:
         return False