Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't compare field count
  • Loading branch information
m-kuhn committed Feb 4, 2016
1 parent 9ad69ad commit 70b4f3a
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions python/testing/__init__.py
Expand Up @@ -45,6 +45,9 @@ def assertLayersEqual(self, layer1, layer2, **kwargs):
:param request: Optional, A feature request. This can be used to specify
an order by clause to make sure features are compared in
a given sequence if they don't match by default.
:keyword compare: A map of comparison options. e.g.
{ fields: { a: skip, b: { precision: 2 }, geometry: { precision: 5 } }
{ fields: { __all__: cast( str ) } }
"""

try:
Expand All @@ -57,14 +60,6 @@ def assertLayersEqual(self, layer1, layer2, **kwargs):
except KeyError:
compare = {}

# Compare fields
_TestCase.assertEqual(self, layer1.fields().count(), layer2.fields().count())
for fieldnum in range(layer1.fields().count()):
field1 = layer1.fields().at(fieldnum)
field2 = layer2.fields().at(fieldnum)
_TestCase.assertEqual(self, field1.name(), field2.name())
# _TestCase.assertEqual(self, field1.type(), field2.type(), 'Field "{}" is not equal: {}({}) != {}({})'.format(field1.name(), field1.typeName(), field1.type(), field2.typeName(), field2.type()))

# Compare CRS
_TestCase.assertEqual(self, layer1.dataProvider().crs().authid(), layer2.dataProvider().crs().authid())

Expand Down Expand Up @@ -131,15 +126,16 @@ def assertLayersEqual(self, layer1, layer2, **kwargs):
self,
attr0,
attr1,
'Features {}/{} differ in attributes\n\n * Field1: {} ({})\n * Field2: {} ({})\n\n * {} != {}'.format(feats[0].id(),
feats[1].id(),
field1.name(),
field1.typeName(),
field2.name(),
field2.typeName(),
repr(attr0),
repr(attr1)
)
'Features {}/{} differ in attributes\n\n * Field1: {} ({})\n * Field2: {} ({})\n\n * {} != {}'.format(
feats[0].id(),
feats[1].id(),
field1.name(),
field1.typeName(),
field2.name(),
field2.typeName(),
repr(attr0),
repr(attr1)
)
)

# Patch unittest
Expand Down

0 comments on commit 70b4f3a

Please sign in to comment.