def submit(self): if self.set_mass.text == "" and self.set_volume.text == "": self.concentration.text = "first enter any value" else: if str_checker(self.set_mass.text) and str_checker(self.set_volume.text): mm = float(self.set_mass.text) vol = float(self.set_volume.text) molar_mass = float(self.mass.text) mol = mm / molar_mass word = str(round((mol / vol), 2)) word += " mol/L" self.concentration.text = word else: self.concentration.text = "enter properly volume and mass"
def test_dot_float_dot(self): self.assertEqual(None, str_checker("1.25."))
def test_not_dot_float(self): self.assertEqual(False, str_checker(".125"))
def test_not_number(self): self.assertEqual(False, str_checker("125a"))
def test_integer(self): self.assertEqual(True, str_checker("125"))
def test_float(self): self.assertEqual(True, str_checker("125.0"))
def test_empty(self): self.assertEqual(None, str_checker(""))