From 2c96b3da6f9be3795bd2ded59175332aa986bf2d Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Fri, 5 Jun 2015 21:56:00 +0100 Subject: [1.8.x] Refs #24937 -- Backported more commits to fix for serialization of Date(Time)RangeField. Instead of using DjangoJSONEncoder, use base_field's value_to_string(). Note this means the serialization of e.g. IntegerRangeField now has strings for lower and upper, so use to_python when they came back in (same behaviour as ArrayField, hopefully, from where I also got the set_attributes_from_name function). Backport of 86d9b10dc33cc115fee2ecab40a569354ac55d15 and 8a842148b6deaab021526e2689279cf5e232945f from master --- tests/postgres_tests/test_ranges.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tests/postgres_tests') diff --git a/tests/postgres_tests/test_ranges.py b/tests/postgres_tests/test_ranges.py index e90c2f8709..feab733161 100644 --- a/tests/postgres_tests/test_ranges.py +++ b/tests/postgres_tests/test_ranges.py @@ -193,18 +193,18 @@ class TestQuerying(TestCase): @skipUnlessPG92 class TestSerialization(TestCase): test_data = ( - '[{"fields": {"ints": "{\\"upper\\": 10, \\"lower\\": 0, ' + '[{"fields": {"ints": "{\\"upper\\": \\"10\\", \\"lower\\": \\"0\\", ' '\\"bounds\\": \\"[)\\"}", "floats": "{\\"empty\\": true}", ' - '"bigints": null, "timestamps": "{\\"upper\\": \\"2014-02-02T12:12:12\\", ' - '\\"lower\\": \\"2014-01-01T00:00:00\\", \\"bounds\\": \\"[)\\"}", ' + '"bigints": null, "timestamps": "{\\"upper\\": \\"2014-02-02T12:12:12+00:00\\", ' + '\\"lower\\": \\"2014-01-01T00:00:00+00:00\\", \\"bounds\\": \\"[)\\"}", ' '"dates": "{\\"upper\\": \\"2014-02-02\\", \\"lower\\": \\"2014-01-01\\", \\"bounds\\": \\"[)\\"}" }, ' '"model": "postgres_tests.rangesmodel", "pk": null}]' ) lower_date = datetime.date(2014, 1, 1) upper_date = datetime.date(2014, 2, 2) - lower_dt = datetime.datetime(2014, 1, 1, 0, 0, 0) - upper_dt = datetime.datetime(2014, 2, 2, 12, 12, 12) + lower_dt = datetime.datetime(2014, 1, 1, 0, 0, 0, tzinfo=timezone.utc) + upper_dt = datetime.datetime(2014, 2, 2, 12, 12, 12, tzinfo=timezone.utc) def test_dumping(self): instance = RangesModel(ints=NumericRange(0, 10), floats=NumericRange(empty=True), -- cgit v1.3