Exemplo n.º 1
0
    def test_invalid_percentage(self):
        with self.assertRaises(ValueError):
            config.Percent("9")

        with self.assertRaises(ValueError):
            config.Percent("-10%")

        with self.assertRaises(ValueError):
            config.Percent("120%")

        with self.assertRaises(ValueError):
            config.Percent("30%%%%")
Exemplo n.º 2
0
 def test_percentage(self):
     self.assertAlmostEqual(config.Percent("37.2%"), .372)
     self.assertAlmostEqual(config.Percent("100%"), 1.0)