diff options
| author | django-bot <ops@djangoproject.com> | 2022-02-03 20:24:19 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-02-07 20:37:05 +0100 |
| commit | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 (patch) | |
| tree | f0506b668a013d0063e5fba3dbf4863b466713ba /tests/gis_tests/test_data.py | |
| parent | f68fa8b45dfac545cfc4111d4e52804c86db68d3 (diff) | |
Refs #33476 -- Reformatted code with Black.
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 ab6e13f558..0a94907320 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.name = name self.ds = get_ds_file(name, ext) @@ -55,6 +54,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 @@ -71,6 +71,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]) @@ -81,9 +82,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)) |
