Skip to content

Commit

Permalink
Added error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
sir-sigurd committed Oct 2, 2018
1 parent 23d0eb9 commit 4f1950e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion django/contrib/gis/geos/coordseq.py
Expand Up @@ -213,5 +213,5 @@ def is_ccw(self):
return area > 0.0
ret = c_byte()
if not capi.cs_is_ccw(self.ptr, byref(ret)):
raise GEOSException
raise GEOSException('Error encountered in GEOS C function "%s".' % capi.cs_is_ccw.func_name)
return ret.value == 1
2 changes: 0 additions & 2 deletions django/contrib/gis/geos/linestring.py
Expand Up @@ -180,6 +180,4 @@ def is_ccw(self):
Return whether or not this LinearRing has counterclockwise
orientation.
"""
if self.empty:
raise GEOSException
return self._cs.is_ccw
6 changes: 6 additions & 0 deletions tests/gis_tests/geos_tests/test_geos.py
Expand Up @@ -744,6 +744,12 @@ def _test_is_ccw(self):
def test_is_ccw_geos(self):
self._test_is_ccw()

@mock.patch('django.contrib.gis.geos.libgeos.geos_version', lambda: b'3.7.0')
@mock.patch('django.contrib.gis.geos.prototypes.cs_is_ccw.func', lambda *args: 0)
def test_is_ccw_geos_error(self):
with self.assertRaisesMessage(GEOSException, 'Error encountered in GEOS C function "GEOSCoordSeq_isCCW".'):
LinearRing().is_ccw

@mock.patch('django.contrib.gis.geos.libgeos.geos_version', lambda: b'3.6.9')
def test_is_ccw_py(self):
self._test_is_ccw()
Expand Down

0 comments on commit 4f1950e

Please sign in to comment.