mirror of
https://github.com/django/django.git
synced 2025-07-24 05:36:15 +00:00
Fixed #24859 -- Made QuerySet.get() with UUIDField raise TypeError on bad value.
For consistency with AutoField.
This commit is contained in:
parent
eaf4d8c0d8
commit
20ff296cb1
2 changed files with 18 additions and 7 deletions
|
@ -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',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue