diff options
| author | Shai Berger <shai@platonix.com> | 2015-06-05 10:32:29 +0300 |
|---|---|---|
| committer | Shai Berger <shai@platonix.com> | 2015-06-05 12:57:20 +0300 |
| commit | 071801ccff970682a799ce754431a3c3ce3d6902 (patch) | |
| tree | 838e774455719f7110b15e74e3d7cb6722e1d8f0 /tests/gis_tests/layermap | |
| parent | 1f28521e0ac81dcc660a5b9891f45a20306e093a (diff) | |
Cleanup: Removed the try-except-fail antipattern from tests
Found cases where testing code was doing
try:
whatever
except (some excption type):
self.fail("exception shouldn't be thrown")
replaced it with just
whatever
as this makes the unexpected errors easier to debug, and the tests
would fail just as much and aren't rendered less readable.
Thanks Markus Holtermann for review
Diffstat (limited to 'tests/gis_tests/layermap')
| -rw-r--r-- | tests/gis_tests/layermap/tests.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/tests/gis_tests/layermap/tests.py b/tests/gis_tests/layermap/tests.py index a0abd4030c..3ebbf4292e 100644 --- a/tests/gis_tests/layermap/tests.py +++ b/tests/gis_tests/layermap/tests.py @@ -140,19 +140,19 @@ class LayerMapTest(TestCase): def test_layermap_unique_multigeometry_fk(self): "Testing the `unique`, and `transform`, geometry collection conversion, and ForeignKey mappings." # All the following should work. - try: - # Telling LayerMapping that we want no transformations performed on the data. - lm = LayerMapping(County, co_shp, co_mapping, transform=False) - # Specifying the source spatial reference system via the `source_srs` keyword. - lm = LayerMapping(County, co_shp, co_mapping, source_srs=4269) - lm = LayerMapping(County, co_shp, co_mapping, source_srs='NAD83') + # Telling LayerMapping that we want no transformations performed on the data. + lm = LayerMapping(County, co_shp, co_mapping, transform=False) - # Unique may take tuple or string parameters. - for arg in ('name', ('name', 'mpoly')): - lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique=arg) - except Exception: - self.fail('No exception should be raised for proper use of keywords.') + # Specifying the source spatial reference system via the `source_srs` keyword. + lm = LayerMapping(County, co_shp, co_mapping, source_srs=4269) + lm = LayerMapping(County, co_shp, co_mapping, source_srs='NAD83') + + # Unique may take tuple or string parameters. + for arg in ('name', ('name', 'mpoly')): + lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique=arg) + + # Now test for failures # Testing invalid params for the `unique` keyword. for e, arg in ((TypeError, 5.0), (ValueError, 'foobar'), (ValueError, ('name', 'mpolygon'))): |
