Skip to content
Permalink
Browse files

Don't rely on a particular order in filterFids tests (#3357)

  • Loading branch information
m-kuhn committed Aug 5, 2016
1 parent 885cc82 commit e82ce54a8e7dc4af8329582b977c144a5380a93f
Showing with 6 additions and 8 deletions.
  1. +3 −2 tests/src/python/providertestbase.py
  2. +3 −6 tests/src/python/test_qgsfeatureiterator.py
@@ -393,12 +393,13 @@ def testGetFeaturesFidsTests(self):
feature = QgsFeature()
feature.setValid(True)
self.assertTrue(feature_it.nextFeature(feature))
self.assertEqual(feature.id(), fids[1])
self.assertIn(feature.id(), [fids[1], fids[3], fids[4]])
first_feature = feature
self.assertTrue(feature.isValid())
# rewind
self.assertTrue(feature_it.rewind())
self.assertTrue(feature_it.nextFeature(feature))
self.assertEqual(feature.id(), fids[1])
self.assertEqual(feature.id(), first_feature.id())
self.assertTrue(feature.isValid())
# grab all features
self.assertTrue(feature_it.nextFeature(feature))
@@ -79,23 +79,20 @@ def test_FilterFids(self):

ids = [feat.id() for feat in pointLayer.getFeatures(QgsFeatureRequest().setFilterFids([7, 8, 12, 30]))]
expectedIds = [7, 8, 12]
myMessage = '\nExpected: {0} features\nGot: {1} features'.format(repr(expectedIds), repr(ids))
assert ids == expectedIds, myMessage
self.assertEquals(set(ids), set(expectedIds))

pointLayer.startEditing()
self.addFeatures(pointLayer)

ids = [feat.id() for feat in pointLayer.getFeatures(QgsFeatureRequest().setFilterFids([-4, 7, 8, 12, 30]))]
expectedIds = [-4, 7, 8, 12]
myMessage = '\nExpected: {0} features\nGot: {1} features'.format(repr(expectedIds), repr(ids))
assert ids == expectedIds, myMessage
self.assertEquals(set(ids), set(expectedIds))

pointLayer.rollBack()

ids = [feat.id() for feat in pointLayer.getFeatures(QgsFeatureRequest().setFilterFids([-2, 7, 8, 12, 30]))]
expectedIds = [7, 8, 12]
myMessage = '\nExpected: {0} features\nGot: {1} features'.format(repr(expectedIds), repr(ids))
assert ids == expectedIds, myMessage
self.assertEquals(set(ids), set(expectedIds))

def addFeatures(self, vl):
feat = QgsFeature()

0 comments on commit e82ce54

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