From d419b0c9bdf6f3de2302974b3e20b8719ca5763e Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Sat, 16 Apr 2016 10:32:43 +0200 Subject: [PATCH] Converted property syntax of WKBWriter --- django/contrib/gis/geos/prototypes/io.py | 16 ++++++++-------- tests/gis_tests/geos_tests/test_io.py | 3 +-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/django/contrib/gis/geos/prototypes/io.py b/django/contrib/gis/geos/prototypes/io.py index 87aec30605..b2f544e5d6 100644 --- a/django/contrib/gis/geos/prototypes/io.py +++ b/django/contrib/gis/geos/prototypes/io.py @@ -233,29 +233,29 @@ class WKBWriter(IOBase): byteorder = property(_get_byteorder, _set_byteorder) # Property for getting/setting the output dimension. - def _get_outdim(self): + @property + def outdim(self): return wkb_writer_get_outdim(self.ptr) - def _set_outdim(self, new_dim): + @outdim.setter + def outdim(self, new_dim): if new_dim not in (2, 3): raise ValueError('WKB output dimension must be 2 or 3') wkb_writer_set_outdim(self.ptr, new_dim) - outdim = property(_get_outdim, _set_outdim) - # Property for getting/setting the include srid flag. - def _get_include_srid(self): + @property + def srid(self): return bool(ord(wkb_writer_get_include_srid(self.ptr))) - def _set_include_srid(self, include): + @srid.setter + def srid(self, include): if include: flag = b'\x01' else: flag = b'\x00' wkb_writer_set_include_srid(self.ptr, flag) - srid = property(_get_include_srid, _set_include_srid) - # `ThreadLocalIO` object holds instances of the WKT and WKB reader/writer # objects that are local to the thread. The `GEOSGeometry` internals diff --git a/tests/gis_tests/geos_tests/test_io.py b/tests/gis_tests/geos_tests/test_io.py index 306824a4a8..e761cd61a3 100644 --- a/tests/gis_tests/geos_tests/test_io.py +++ b/tests/gis_tests/geos_tests/test_io.py @@ -101,9 +101,8 @@ class GEOSIOTest(SimpleTestCase): # Ensuring bad output dimensions are not accepted for bad_outdim in (-1, 0, 1, 4, 423, 'foo', None): - # Equivalent of `wkb_w.outdim = bad_outdim` with self.assertRaises(ValueError): - wkb_w._set_outdim(bad_outdim) + wkb_w.outdim = bad_outdim # Now setting the output dimensions to be 3 wkb_w.outdim = 3