Beispiel #1
0
    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"
Beispiel #2
0
 def test_dot_float_dot(self):
     self.assertEqual(None, str_checker("1.25."))
Beispiel #3
0
 def test_not_dot_float(self):
     self.assertEqual(False, str_checker(".125"))
Beispiel #4
0
 def test_not_number(self):
     self.assertEqual(False, str_checker("125a"))
Beispiel #5
0
 def test_integer(self):
     self.assertEqual(True, str_checker("125"))
Beispiel #6
0
 def test_float(self):
     self.assertEqual(True, str_checker("125.0"))
Beispiel #7
0
 def test_empty(self):
     self.assertEqual(None, str_checker(""))