Replaced caching of a property with @cached_property.
This commit is contained in:
parent
9d3d1a0321
commit
45db7f7db8
|
@ -8,11 +8,9 @@ import os
|
||||||
from django.contrib import gis
|
from django.contrib import gis
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from django.utils._os import upath
|
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.
|
# Path where reference test data is located.
|
||||||
TEST_DATA = os.path.join(os.path.dirname(upath(gis.__file__)), 'tests', 'data')
|
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`
|
Mixin used for GEOS/GDAL test cases that defines a `geometries`
|
||||||
property, which returns and/or loads the reference geometry data.
|
property, which returns and/or loads the reference geometry data.
|
||||||
"""
|
"""
|
||||||
@property
|
@cached_property
|
||||||
def geometries(self):
|
def geometries(self):
|
||||||
global GEOMETRIES
|
# Load up the test geometry data from fixture into global.
|
||||||
if GEOMETRIES is None:
|
with open(os.path.join(TEST_DATA, 'geometries.json')) as f:
|
||||||
# Load up the test geometry data from fixture into global.
|
geometries = json.load(f)
|
||||||
with open(os.path.join(TEST_DATA, 'geometries.json')) as f:
|
return TestGeomSet(**strconvert(geometries))
|
||||||
geometries = json.load(f)
|
|
||||||
GEOMETRIES = TestGeomSet(**strconvert(geometries))
|
|
||||||
return GEOMETRIES
|
|
||||||
|
|
Loading…
Reference in New Issue