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