summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2016-04-16 10:32:43 +0200
committerClaude Paroz <claude@2xlibre.net>2016-04-16 19:51:00 +0200
commitd419b0c9bdf6f3de2302974b3e20b8719ca5763e (patch)
treefdac4a488ae0dfa2561b3a21a6c20ffae18348a2
parent393811c67a04130fd387a502b16d85dc8aa135a2 (diff)
Converted property syntax of WKBWriter
-rw-r--r--django/contrib/gis/geos/prototypes/io.py16
-rw-r--r--tests/gis_tests/geos_tests/test_io.py3
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