summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-01-07 18:50:06 -0500
committerTim Graham <timograham@gmail.com>2016-01-07 18:54:41 -0500
commit59ef6559a31c175c1f52668ef0ffe9b8d87aa5a5 (patch)
treeebb1c6c4846cd0c6a1c1295ff791502d728a42d5 /tests
parent7f218d98915ef3e76a98ef72075a6bde907dfe41 (diff)
Reverted #25961 -- Removed handling of thread-non-safe GEOS functions.
This reverts commit 312fc1af7b8a028611b45ee272652d59ea7bd85a as it seems to cause segmentation faults as described in the ticket.
Diffstat (limited to 'tests')
-rw-r--r--tests/gis_tests/geos_tests/test_geos.py45
1 files changed, 1 insertions, 44 deletions
diff --git a/tests/gis_tests/geos_tests/test_geos.py b/tests/gis_tests/geos_tests/test_geos.py
index 8c67139e92..116e8d35f8 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 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()
-
- # We can't be sure that members of thread locals are
- # garbage collected right after `thread.join()` so
- # we must wait until destructor is actually called.
- # Fail if destructor wasn't called within a second.
- 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)
-
- # Check that different contexts were used for the different threads.
- 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)