summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2014-11-19 21:53:24 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2014-11-19 21:53:24 +0100
commit45db7f7db85ea490fa914fa57ac943d83a6c07f1 (patch)
treed0e44b3cd5aa38cf03cb253a6ac2d9e69e76a6f5
parent9d3d1a03214c3f40f9c3bb61b78a380b0f7a77cd (diff)
Replaced caching of a property with @cached_property.
-rw-r--r--django/contrib/gis/geometry/test_data.py17
1 files changed, 6 insertions, 11 deletions
diff --git a/django/contrib/gis/geometry/test_data.py b/django/contrib/gis/geometry/test_data.py
index 6bab165e07..3ad2f4aaea 100644
--- a/django/contrib/gis/geometry/test_data.py
+++ b/django/contrib/gis/geometry/test_data.py
@@ -8,11 +8,9 @@ import os
from django.contrib import gis
from django.utils import six
from django.utils._os import upath
+from django.utils.functional import cached_property
-# This global used to store reference geometry data.
-GEOMETRIES = None
-
# Path where reference test data is located.
TEST_DATA = os.path.join(os.path.dirname(upath(gis.__file__)), 'tests', 'data')
@@ -95,12 +93,9 @@ class TestDataMixin(object):
Mixin used for GEOS/GDAL test cases that defines a `geometries`
property, which returns and/or loads the reference geometry data.
"""
- @property
+ @cached_property
def geometries(self):
- global GEOMETRIES
- if GEOMETRIES is None:
- # Load up the test geometry data from fixture into global.
- with open(os.path.join(TEST_DATA, 'geometries.json')) as f:
- geometries = json.load(f)
- GEOMETRIES = TestGeomSet(**strconvert(geometries))
- return GEOMETRIES
+ # Load up the test geometry data from fixture into global.
+ with open(os.path.join(TEST_DATA, 'geometries.json')) as f:
+ geometries = json.load(f)
+ return TestGeomSet(**strconvert(geometries))