|
@@ -3,7 +3,6 @@ from __future__ import unicode_literals
|
|
|
import ctypes
|
|
|
import json
|
|
|
import random
|
|
|
-import threading
|
|
|
from binascii import a2b_hex, b2a_hex
|
|
|
from io import BytesIO
|
|
|
from unittest import skipUnless
|
|
@@ -13,7 +12,7 @@ from django.contrib.gis.gdal import HAS_GDAL
|
|
|
from django.contrib.gis.geos import (
|
|
|
HAS_GEOS, GeometryCollection, GEOSException, GEOSGeometry, LinearRing,
|
|
|
LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon,
|
|
|
- fromfile, fromstr, libgeos,
|
|
|
+ fromfile, fromstr,
|
|
|
)
|
|
|
from django.contrib.gis.geos.base import GEOSBase
|
|
|
from django.contrib.gis.geos.libgeos import geos_version_info
|
|
@@ -1233,48 +1232,6 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
|
|
|
self.assertEqual(m.group('version'), v_geos)
|
|
|
self.assertEqual(m.group('capi_version'), v_capi)
|
|
|
|
|
|
- def test_geos_threads(self):
|
|
|
- pnt = Point()
|
|
|
- context_ptrs = []
|
|
|
-
|
|
|
- geos_init = libgeos.lgeos.initGEOS_r
|
|
|
- geos_finish = libgeos.lgeos.finishGEOS_r
|
|
|
-
|
|
|
- def init(*args, **kwargs):
|
|
|
- result = geos_init(*args, **kwargs)
|
|
|
- context_ptrs.append(result)
|
|
|
- return result
|
|
|
-
|
|
|
- def finish(*args, **kwargs):
|
|
|
- result = geos_finish(*args, **kwargs)
|
|
|
- destructor_called.set()
|
|
|
- return result
|
|
|
-
|
|
|
- for i in range(2):
|
|
|
- destructor_called = threading.Event()
|
|
|
- patch_path = 'django.contrib.gis.geos.libgeos.lgeos'
|
|
|
- with mock.patch.multiple(patch_path, initGEOS_r=mock.DEFAULT, finishGEOS_r=mock.DEFAULT) as mocked:
|
|
|
- mocked['initGEOS_r'].side_effect = init
|
|
|
- mocked['finishGEOS_r'].side_effect = finish
|
|
|
- with mock.patch('django.contrib.gis.geos.prototypes.predicates.geos_hasz.func') as mocked_hasz:
|
|
|
- thread = threading.Thread(target=lambda: pnt.hasz)
|
|
|
- thread.start()
|
|
|
- thread.join()
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- self.assertTrue(destructor_called.wait(1))
|
|
|
-
|
|
|
- context_ptr = context_ptrs[i]
|
|
|
- self.assertIsInstance(context_ptr, libgeos.CONTEXT_PTR)
|
|
|
- mocked_hasz.assert_called_once_with(context_ptr, pnt.ptr)
|
|
|
- mocked['finishGEOS_r'].assert_called_once_with(context_ptr)
|
|
|
-
|
|
|
-
|
|
|
- self.assertNotEqual(context_ptrs[0], context_ptrs[1])
|
|
|
-
|
|
|
@ignore_warnings(category=RemovedInDjango20Warning)
|
|
|
def test_deprecated_srid_getters_setters(self):
|
|
|
p = Point(1, 2, srid=123)
|