class FloatFieldTest(unittest.TestCase): """ Tests for :class:`lofarpipe.support.lofaringredient.FloatField` """ def setUp(self): from lofarpipe.support.lofaringredient import FloatField self.floatfield = FloatField(default=1.0) def test_validator(self): """ Check that floats are correctly regarded as valid, and strings aren't. """ self.assertFalse(self.floatfield.is_valid("1")) self.assertTrue(self.floatfield.is_valid(1.0)) def test_default(self): """ Check that default is correctly set. """ self.assertEqual(self.floatfield.default, 1.0) def test_coerce(self): """ Check that a string is correctly coerced to an float. """ self.assertEqual(self.floatfield.coerce("1"), 1.0)
def setUp(self): from lofarpipe.support.lofaringredient import FloatField self.floatfield = FloatField(default=1.0)