diff options
Diffstat (limited to 'tests/model_fields/test_floatfield.py')
| -rw-r--r-- | tests/model_fields/test_floatfield.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/model_fields/test_floatfield.py b/tests/model_fields/test_floatfield.py index 481925cf11..856197cd6e 100644 --- a/tests/model_fields/test_floatfield.py +++ b/tests/model_fields/test_floatfield.py @@ -31,3 +31,20 @@ class TestFloatField(TestCase): obj.size = obj with self.assertRaisesMessage(TypeError, msg): obj.save() + + def test_invalid_value(self): + tests = [ + (TypeError, ()), + (TypeError, []), + (TypeError, {}), + (TypeError, set()), + (TypeError, object()), + (TypeError, complex()), + (ValueError, 'non-numeric string'), + (ValueError, b'non-numeric byte-string'), + ] + for exception, value in tests: + with self.subTest(value): + msg = "Field 'size' expected a number but got %r." % (value,) + with self.assertRaisesMessage(exception, msg): + FloatModel.objects.create(size=value) |
