diff options
| author | Cole Maclean <hi@cole.io> | 2015-06-04 14:42:26 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-06-06 19:46:05 -0400 |
| commit | 20ff296cb15a53b8b9517a834688e57749b43e21 (patch) | |
| tree | 20a9eccc43e45cdce75fe3cf280a95cc43a2300d /tests | |
| parent | eaf4d8c0d85056c3481986fe092d5a8786bc4f26 (diff) | |
Fixed #24859 -- Made QuerySet.get() with UUIDField raise TypeError on bad value.
For consistency with AutoField.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/model_fields/test_uuid.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/model_fields/test_uuid.py b/tests/model_fields/test_uuid.py index e72a6bce56..bef1d54a74 100644 --- a/tests/model_fields/test_uuid.py +++ b/tests/model_fields/test_uuid.py @@ -37,6 +37,13 @@ class TestSaveLoad(TestCase): loaded = NullableUUIDModel.objects.get() self.assertEqual(loaded.field, None) + def test_pk_validated(self): + with self.assertRaisesMessage(TypeError, 'is not a valid UUID'): + PrimaryKeyUUIDModel.objects.get(pk={}) + + with self.assertRaisesMessage(TypeError, 'is not a valid UUID'): + PrimaryKeyUUIDModel.objects.get(pk=[]) + def test_wrong_value(self): self.assertRaisesMessage( ValueError, 'badly formed hexadecimal UUID string', |
