Skip to content
Permalink
Browse files

Don't compare field count

  • Loading branch information
m-kuhn committed Feb 4, 2016
1 parent 9ad69ad commit 70b4f3a24228c855a6cbb4e2f9df6098a38eda19
Showing with 13 additions and 17 deletions.
  1. +13 −17 python/testing/__init__.py
@@ -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:
@@ -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())

@@ -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

0 comments on commit 70b4f3a

Please sign in to comment.
You can’t perform that action at this time.