diff options
| author | Sergey Fedoseev <fedoseev.sergey@gmail.com> | 2015-11-05 13:25:44 +0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-11-18 18:36:10 -0500 |
| commit | 1e35dd1a053b620f065101c02069c8e142ebf8ec (patch) | |
| tree | a54b454c66f20d3f52bbf292748f65571f5005f2 /tests | |
| parent | 7a452c5ce295679307bd81dd9b5f37b3cf762acf (diff) | |
Fixed #25663 -- Added checking of the number of points for LinearRing and LineString.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/gis_tests/geos_tests/test_geos.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/tests/gis_tests/geos_tests/test_geos.py b/tests/gis_tests/geos_tests/test_geos.py index 683d00c89f..d983af98ea 100644 --- a/tests/gis_tests/geos_tests/test_geos.py +++ b/tests/gis_tests/geos_tests/test_geos.py @@ -3,7 +3,6 @@ from __future__ import unicode_literals import ctypes import json import random -import unittest from binascii import a2b_hex, b2a_hex from io import BytesIO from unittest import skipUnless @@ -19,7 +18,7 @@ from django.contrib.gis.geos.base import GEOSBase from django.contrib.gis.shortcuts import numpy from django.template import Context from django.template.engine import Engine -from django.test import ignore_warnings, mock +from django.test import SimpleTestCase, ignore_warnings, mock from django.utils import six from django.utils.deprecation import RemovedInDjango20Warning from django.utils.encoding import force_bytes @@ -29,7 +28,7 @@ from ..test_data import TestDataMixin @skipUnless(HAS_GEOS, "Geos is required.") -class GEOSTest(unittest.TestCase, TestDataMixin): +class GEOSTest(SimpleTestCase, TestDataMixin): def test_base(self): "Tests out the GEOSBase class." @@ -326,6 +325,12 @@ class GEOSTest(unittest.TestCase, TestDataMixin): if numpy: self.assertEqual(ls, LineString(numpy.array(ls.tuple))) # as numpy array + with self.assertRaisesMessage(TypeError, 'Each coordinate should be a sequence (list or tuple)'): + LineString((0, 0)) + + with self.assertRaisesMessage(TypeError, 'LineString requires at least 2 points, got 1.'): + LineString([(0, 0)]) + def test_multilinestring(self): "Testing MultiLineString objects." prev = fromstr('POINT(0 0)') @@ -369,6 +374,12 @@ class GEOSTest(unittest.TestCase, TestDataMixin): if numpy: self.assertEqual(lr, LinearRing(numpy.array(lr.tuple))) + with self.assertRaisesMessage(TypeError, 'LinearRing requires at least 4 points, got 3.'): + LinearRing((0, 0), (1, 1), (0, 0)) + + with self.assertRaisesMessage(TypeError, 'LinearRing requires at least 4 points, got 1.'): + LinearRing([(0, 0)]) + def test_polygons_from_bbox(self): "Testing `from_bbox` class method." bbox = (-180, -90, 180, 90) |
