mirror of https://github.com/django/django.git
Fixed #25665 -- Deprecated getter/setter of Point.tuple.
This commit is contained in:
parent
7803f429a4
commit
7a452c5ce2
|
@ -172,14 +172,29 @@ class Point(GEOSGeometry):
|
||||||
self.z = value
|
self.z = value
|
||||||
|
|
||||||
# ### Tuple setting and retrieval routines. ###
|
# ### Tuple setting and retrieval routines. ###
|
||||||
def get_coords(self):
|
@property
|
||||||
|
def tuple(self):
|
||||||
"Returns a tuple of the point."
|
"Returns a tuple of the point."
|
||||||
return self._cs.tuple
|
return self._cs.tuple
|
||||||
|
|
||||||
def set_coords(self, tup):
|
@tuple.setter
|
||||||
|
def tuple(self, tup):
|
||||||
"Sets the coordinates of the point with the given tuple."
|
"Sets the coordinates of the point with the given tuple."
|
||||||
self._cs[0] = tup
|
self._cs[0] = tup
|
||||||
|
|
||||||
|
def get_coords(self):
|
||||||
|
warnings.warn(
|
||||||
|
"`get_coords()` is deprecated, use the `tuple` property instead.",
|
||||||
|
RemovedInDjango20Warning, 2
|
||||||
|
)
|
||||||
|
return self.tuple
|
||||||
|
|
||||||
|
def set_coords(self, tup):
|
||||||
|
warnings.warn(
|
||||||
|
"`set_coords()` is deprecated, use the `tuple` property instead.",
|
||||||
|
RemovedInDjango20Warning, 2
|
||||||
|
)
|
||||||
|
self.tuple = tup
|
||||||
|
|
||||||
# The tuple and coords properties
|
# The tuple and coords properties
|
||||||
tuple = property(get_coords, set_coords)
|
|
||||||
coords = tuple
|
coords = tuple
|
||||||
|
|
|
@ -118,6 +118,9 @@ details on these changes.
|
||||||
* The ``get_x()``, ``set_x()``, ``get_y()``, ``set_y()``, ``get_z()``, and
|
* The ``get_x()``, ``set_x()``, ``get_y()``, ``set_y()``, ``get_z()``, and
|
||||||
``set_z()`` methods of ``django.contrib.gis.geos.Point`` will be removed.
|
``set_z()`` methods of ``django.contrib.gis.geos.Point`` will be removed.
|
||||||
|
|
||||||
|
* The ``get_coords()`` and ``set_coords()`` methods of
|
||||||
|
``django.contrib.gis.geos.Point`` will be removed.
|
||||||
|
|
||||||
.. _deprecation-removed-in-1.10:
|
.. _deprecation-removed-in-1.10:
|
||||||
|
|
||||||
1.10
|
1.10
|
||||||
|
|
|
@ -339,6 +339,10 @@ This prevents confusion about an assignment resulting in an implicit save.
|
||||||
``set_z()`` methods of :class:`~django.contrib.gis.geos.Point` are deprecated
|
``set_z()`` methods of :class:`~django.contrib.gis.geos.Point` are deprecated
|
||||||
in favor of the ``x``, ``y``, and ``z`` properties.
|
in favor of the ``x``, ``y``, and ``z`` properties.
|
||||||
|
|
||||||
|
* The ``get_coords()`` and ``set_coords()`` methods of
|
||||||
|
:class:`~django.contrib.gis.geos.Point` are deprecated in favor of the
|
||||||
|
``tuple`` property.
|
||||||
|
|
||||||
Miscellaneous
|
Miscellaneous
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
|
@ -787,7 +787,8 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
||||||
# Testing a 3D Point
|
# Testing a 3D Point
|
||||||
pnt = Point(2, 3, 8)
|
pnt = Point(2, 3, 8)
|
||||||
self.assertEqual((2., 3., 8.), pnt.coords)
|
self.assertEqual((2., 3., 8.), pnt.coords)
|
||||||
self.assertRaises(TypeError, pnt.set_coords, (1., 2.))
|
with self.assertRaises(TypeError):
|
||||||
|
pnt.tuple = (1., 2.)
|
||||||
pnt.coords = (1., 2., 3.)
|
pnt.coords = (1., 2., 3.)
|
||||||
self.assertEqual((1., 2., 3.), pnt.coords)
|
self.assertEqual((1., 2., 3.), pnt.coords)
|
||||||
|
|
||||||
|
@ -1156,6 +1157,14 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
||||||
self.assertEqual((p.get_x(), p.get_y(), p.get_z()), (p.x, p.y, p.z))
|
self.assertEqual((p.get_x(), p.get_y(), p.get_z()), (p.x, p.y, p.z))
|
||||||
|
|
||||||
p.set_x(3)
|
p.set_x(3)
|
||||||
p.set_y(1)
|
p.set_y(2)
|
||||||
p.set_z(2)
|
p.set_z(1)
|
||||||
self.assertEqual((p.x, p.y, p.z), (3, 1, 2))
|
self.assertEqual((p.x, p.y, p.z), (3, 2, 1))
|
||||||
|
|
||||||
|
@ignore_warnings(category=RemovedInDjango20Warning)
|
||||||
|
def test_deprecated_point_tuple_getters_setters(self):
|
||||||
|
p = Point(1, 2, 3)
|
||||||
|
self.assertEqual(p.get_coords(), (p.x, p.y, p.z))
|
||||||
|
|
||||||
|
p.set_coords((3, 2, 1))
|
||||||
|
self.assertEqual(p.get_coords(), (3, 2, 1))
|
||||||
|
|
Loading…
Reference in New Issue