1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed deepcopy of AreaField and DistanceField.

This commit is contained in:
Sergey Fedoseev 2017-07-07 17:54:08 +05:00 committed by Tim Graham
parent 0c4ac12a7b
commit 0ab1dc0a8b
2 changed files with 17 additions and 0 deletions

View File

@ -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):

View File

@ -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)