mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #29869 -- Made UUIDField.to_python() convert integers.
This commit is contained in:
committed by
Tim Graham
parent
fd49701ab9
commit
83c7096f2a
@@ -64,6 +64,22 @@ class TestMethods(SimpleTestCase):
|
||||
def test_to_python(self):
|
||||
self.assertIsNone(models.UUIDField().to_python(None))
|
||||
|
||||
def test_to_python_int_values(self):
|
||||
self.assertEqual(
|
||||
models.UUIDField().to_python(0),
|
||||
uuid.UUID('00000000-0000-0000-0000-000000000000')
|
||||
)
|
||||
# Works for integers less than 128 bits.
|
||||
self.assertEqual(
|
||||
models.UUIDField().to_python((2 ** 128) - 1),
|
||||
uuid.UUID('ffffffff-ffff-ffff-ffff-ffffffffffff')
|
||||
)
|
||||
|
||||
def test_to_python_int_too_large(self):
|
||||
# Fails for integers larger than 128 bits.
|
||||
with self.assertRaises(exceptions.ValidationError):
|
||||
models.UUIDField().to_python(2 ** 128)
|
||||
|
||||
|
||||
class TestQuerying(TestCase):
|
||||
def setUp(self):
|
||||
|
||||
Reference in New Issue
Block a user