diff options
Diffstat (limited to 'tests/gis_tests/test_data.py')
| -rw-r--r-- | tests/gis_tests/test_data.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/tests/gis_tests/test_data.py b/tests/gis_tests/test_data.py index dca847e8cb..e0289a369a 100644 --- a/tests/gis_tests/test_data.py +++ b/tests/gis_tests/test_data.py @@ -8,7 +8,7 @@ import os from django.utils.functional import cached_property # Path where reference test data is located. -TEST_DATA = os.path.join(os.path.dirname(__file__), 'data') +TEST_DATA = os.path.join(os.path.dirname(__file__), "data") def tuplize(seq): @@ -24,16 +24,14 @@ def strconvert(d): def get_ds_file(name, ext): - return os.path.join(TEST_DATA, - name, - name + '.%s' % ext - ) + return os.path.join(TEST_DATA, name, name + ".%s" % ext) class TestObj: """ Base testing object, turns keyword args into attributes. """ + def __init__(self, **kwargs): for key, value in kwargs.items(): setattr(self, key, value) @@ -43,7 +41,8 @@ class TestDS(TestObj): """ Object for testing GDAL data sources. """ - def __init__(self, name, *, ext='shp', **kwargs): + + def __init__(self, name, *, ext="shp", **kwargs): # Shapefile is default extension, unless specified otherwise. self.ds = get_ds_file(name, ext) super().__init__(**kwargs) @@ -54,6 +53,7 @@ class TestGeom(TestObj): Testing object used for wrapping reference geometry data in GEOS/GDAL tests. """ + def __init__(self, *, coords=None, centroid=None, ext_ring_cs=None, **kwargs): # Converting lists to tuples of certain keyword args # so coordinate test cases will match (JSON has no @@ -70,6 +70,7 @@ class TestGeomSet: """ Each attribute of this object is a list of `TestGeom` instances. """ + def __init__(self, **kwargs): for key, value in kwargs.items(): setattr(self, key, [TestGeom(**strconvert(kw)) for kw in value]) @@ -80,9 +81,10 @@ class TestDataMixin: Mixin used for GEOS/GDAL test cases that defines a `geometries` property, which returns and/or loads the reference geometry data. """ + @cached_property def geometries(self): # Load up the test geometry data from fixture into global. - with open(os.path.join(TEST_DATA, 'geometries.json')) as f: + with open(os.path.join(TEST_DATA, "geometries.json")) as f: geometries = json.load(f) return TestGeomSet(**strconvert(geometries)) |
