Skip to content

Commit

Permalink
Avoid key error on fields which should be skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 7, 2016
1 parent c975764 commit 1bdb35d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions python/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ def assertLayersEqual(self, layer_expected, layer_result, **kwargs):
)

for attr_expected, field_expected in zip(feats[0].attributes(), layer_expected.fields().toList()):
attr_result = feats[1][field_expected.name()]
field_result = [fld for fld in layer_expected.fields().toList() if fld.name() == field_expected.name()][0]
try:
cmp = compare['fields'][field_expected.name()]
except KeyError:
Expand All @@ -116,6 +114,9 @@ def assertLayersEqual(self, layer_expected, layer_result, **kwargs):
if 'skip' in cmp:
continue

attr_result = feats[1][field_expected.name()]
field_result = [fld for fld in layer_expected.fields().toList() if fld.name() == field_expected.name()][0]

# Cast field to a given type
if 'cast' in cmp:
if cmp['cast'] == 'int':
Expand Down

0 comments on commit 1bdb35d

Please sign in to comment.