diff options
| author | Lukas Hetzenecker <lukas@splots.co> | 2015-06-23 22:56:22 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2015-07-10 09:02:14 +0200 |
| commit | ebcfedb0e541a4840c375375ab41fc513f322b7d (patch) | |
| tree | 2a9ffdf93f54a2e624d794d7c6dbf870b8a38003 /tests/httpwrappers | |
| parent | 0db2cdb1fa9e08658d78ff58ea9bd698ea12d3fa (diff) | |
[1.8.x] Fixed #25019 -- Added UUID support in DjangoJSONEncoder
Backport of 6355a6d4f5 and 2e05ef4e18 from master.
Diffstat (limited to 'tests/httpwrappers')
| -rw-r--r-- | tests/httpwrappers/tests.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/httpwrappers/tests.py b/tests/httpwrappers/tests.py index 25da7b622c..c7bf63b4ca 100644 --- a/tests/httpwrappers/tests.py +++ b/tests/httpwrappers/tests.py @@ -6,6 +6,7 @@ import json import os import pickle import unittest +import uuid from django.core.exceptions import SuspiciousOperation from django.core.serializers.json import DjangoJSONEncoder @@ -480,6 +481,11 @@ class JsonResponseTests(TestCase): response = JsonResponse(['foo', 'bar'], safe=False) self.assertEqual(json.loads(response.content.decode()), ['foo', 'bar']) + def test_json_response_uuid(self): + u = uuid.uuid4() + response = JsonResponse(u, safe=False) + self.assertEqual(json.loads(response.content.decode()), str(u)) + def test_json_response_custom_encoder(self): class CustomDjangoJSONEncoder(DjangoJSONEncoder): def encode(self, o): |
