Пример #1
0
    def test_float_parser_raises_error(self):
        """
        Tests that the float parser raises a FieldValueParsingError
        with a INVALID_FLOAT_VALUE message if the given string is not
        a float.
        """
        with self.assertRaises(FieldValueParsingError) as error:
            FieldValueParsers.float_parser('meh')

        self.assertEqual(
            str(error.exception),
            FieldValueParsers.INVALID_FLOAT_VALUE.format('meh'),
        )
Пример #2
0
 def test_float_parser_returns_float(self):
     """
     Tests that the float parser parses a float.
     """
     self.assertEqual(FieldValueParsers.float_parser('4.5'), 4.5)