From 0ab1dc0a8bfc580e92ad4af413ab3fd3797f0d2a Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Fri, 7 Jul 2017 17:54:08 +0500 Subject: [PATCH] Fixed deepcopy of AreaField and DistanceField. --- django/contrib/gis/db/models/sql/conversion.py | 2 ++ tests/gis_tests/test_fields.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 tests/gis_tests/test_fields.py diff --git a/django/contrib/gis/db/models/sql/conversion.py b/django/contrib/gis/db/models/sql/conversion.py index d9b79f237d..eafa7b5d17 100644 --- a/django/contrib/gis/db/models/sql/conversion.py +++ b/django/contrib/gis/db/models/sql/conversion.py @@ -11,6 +11,7 @@ from django.db import models class AreaField(models.FloatField): "Wrapper for Area values." def __init__(self, area_att=None): + super().__init__() self.area_att = area_att def get_prep_value(self, value): @@ -40,6 +41,7 @@ class AreaField(models.FloatField): class DistanceField(models.FloatField): "Wrapper for Distance values." def __init__(self, distance_att=None): + super().__init__() self.distance_att = distance_att def get_prep_value(self, value): diff --git a/tests/gis_tests/test_fields.py b/tests/gis_tests/test_fields.py new file mode 100644 index 0000000000..fb0c953f21 --- /dev/null +++ b/tests/gis_tests/test_fields.py @@ -0,0 +1,15 @@ +import copy + +from django.contrib.gis.db.models.sql import AreaField, DistanceField +from django.test import SimpleTestCase + + +class FieldsTests(SimpleTestCase): + + def test_area_field_deepcopy(self): + field = AreaField() + self.assertEqual(copy.deepcopy(field), field) + + def test_distance_field_deepcopy(self): + field = DistanceField() + self.assertEqual(copy.deepcopy(field), field)