Exemple #1
0
class FloatTypeTests(TypeTestHelper, unittest.TestCase):
    type = types.Float()

    def test_decimal_format(self):
        v = self.type_instance('123.456')
        self.assertAlmostEqual(v, 123.456)

    def test_decimal_format_negative_float(self):
        v = self.type_instance('-123.456')
        self.assertAlmostEqual(v, -123.456)

    def test_exponential_format(self):
        v = self.type_instance('123e-2')
        self.assertAlmostEqual(v, 1.23)

    def test_non_float_is_invalid(self):
        self.assertInvalid('123,345')
        self.assertInvalid('foo')

    def test_repr(self):
        self.assertEqual('Float', repr(types.Float()))

    def test_equal(self):
        self.assertTrue(types.Float() == types.Float())

    def test_not_equal_to_other_class(self):
        self.assertFalse(types.Float() == types.Integer())
Exemple #2
0
 def test_not_equal_to_other_class(self):
     self.assertFalse(types.Float() == types.Integer())
Exemple #3
0
 def test_equal(self):
     self.assertTrue(types.Float() == types.Float())
Exemple #4
0
 def test_repr(self):
     self.assertEqual('Float', repr(types.Float()))