Skip to content
Permalink
Browse files

Run next_call fixer on tests

  • Loading branch information
m-kuhn committed Apr 15, 2016
1 parent 8303688 commit c268f7e9967d8799157d32cd9c0ad5f9f10e0d27
@@ -70,7 +70,7 @@ def testDateTimeTypes(self):
self.assertEqual(fields.at(fields.indexFromName(
'datetime_field')).type(), QVariant.DateTime)

f = vl.getFeatures(QgsFeatureRequest()).next()
f = next(vl.getFeatures(QgsFeatureRequest()))

date_idx = vl.fieldNameIndex('date_field')
assert isinstance(f.attributes()[date_idx], QDate)
@@ -79,7 +79,7 @@ def testDateTimeTypes(self):
self.assertEqual(fields.at(fields.indexFromName('time_field')).type(), QVariant.Time)
self.assertEqual(fields.at(fields.indexFromName('datetime_field')).type(), QVariant.DateTime)

f = vl.getFeatures(QgsFeatureRequest()).next()
f = next(vl.getFeatures(QgsFeatureRequest()))

date_idx = vl.fieldNameIndex('date_field')
self.assertTrue(isinstance(f.attributes()[date_idx], QDate))
@@ -40,7 +40,7 @@ def testDateTimeFormats(self):
self.assertEqual(fields.at(fields.indexFromName('time')).type(), QVariant.Time)
self.assertEqual(fields.at(fields.indexFromName('date_time')).type(), QVariant.DateTime)

f = vl.getFeatures(QgsFeatureRequest()).next()
f = next(vl.getFeatures(QgsFeatureRequest()))

date_idx = vl.fieldNameIndex('date')
assert isinstance(f.attributes()[date_idx], QDate)
@@ -105,7 +105,7 @@ def test_getRelatedFeatures(self):
rel.setReferencedLayer(self.referencedLayer.id())
rel.addFieldPair('foreignkey', 'y')

feat = self.referencedLayer.getFeatures().next()
feat = next(self.referencedLayer.getFeatures())

it = rel.getRelatedFeatures(feat)

@@ -119,7 +119,7 @@ def test_getReferencedFeature(self):
rel.setReferencedLayer(self.referencedLayer.id())
rel.addFieldPair('foreignkey', 'y')

feat = self.referencingLayer.getFeatures().next()
feat = next(self.referencingLayer.getFeatures())

f = rel.getReferencedFeature(feat)

@@ -173,7 +173,7 @@ def choose_linked_feature():
btn.click()
# magically the above code selects the feature here...

link_feature = self.vl_link.getFeatures(QgsFeatureRequest().setFilterExpression('"fk_book"={}'.format(f[0]))).next()
link_feature = next(self.vl_link.getFeatures(QgsFeatureRequest().setFilterExpression('"fk_book"={}'.format(f[0]))))
self.assertIsNotNone(link_feature[0])

self.assertEquals(self.table_view.model().rowCount(), 1)
@@ -258,7 +258,7 @@ def createWrapper(self, layer, filter=None):
request = QgsFeatureRequest()
if filter:
request.setFilterExpression(filter)
book = layer.getFeatures(request).next()
book = next(layer.getFeatures(request))
self.wrapper.setFeature(book)

self.table_view = self.widget.findChild(QTableView)
@@ -99,7 +99,7 @@ def testDateTimeWriteShapefile(self):
#shapefiles do not support datetime types, result should be string
self.assertEqual(fields.at(fields.indexFromName('dt_f')).type(), QVariant.String)

f = created_layer.getFeatures(QgsFeatureRequest()).next()
f = next(created_layer.getFeatures(QgsFeatureRequest()))

date_idx = created_layer.fieldNameIndex('date_f')
assert isinstance(f.attributes()[date_idx], QDate)
@@ -152,7 +152,7 @@ def testDateTimeWriteTabfile(self):
self.assertEqual(fields.at(fields.indexFromName('time_f')).type(), QVariant.Time)
self.assertEqual(fields.at(fields.indexFromName('dt_f')).type(), QVariant.DateTime)

f = created_layer.getFeatures(QgsFeatureRequest()).next()
f = next(created_layer.getFeatures(QgsFeatureRequest()))

date_idx = created_layer.fieldNameIndex('date_f')
assert isinstance(f.attributes()[date_idx], QDate)
@@ -201,7 +201,7 @@ def testWriteShapefileWithZ(self):

# Open result and check
created_layer = QgsVectorLayer(u'{}|layerid=0'.format(dest_file_name), u'test', u'ogr')
f = created_layer.getFeatures(QgsFeatureRequest()).next()
f = next(created_layer.getFeatures(QgsFeatureRequest()))
g = f.geometry()
wkt = g.exportToWkt()
expWkt = 'PointZ (1 2 3)'
@@ -223,7 +223,7 @@ def testWriteShapefileWithZ(self):

# Open result and check
created_layer_from_shp = QgsVectorLayer(u'{}|layerid=0'.format(dest_file_name), u'test', u'ogr')
f = created_layer_from_shp.getFeatures(QgsFeatureRequest()).next()
f = next(created_layer_from_shp.getFeatures(QgsFeatureRequest()))
g = f.geometry()
wkt = g.exportToWkt()
assert compareWkt(expWkt, wkt), "saving geometry with Z failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)
@@ -261,7 +261,7 @@ def testWriteShapefileWithMultiConversion(self):

# Open result and check
created_layer = QgsVectorLayer(u'{}|layerid=0'.format(dest_file_name), u'test', u'ogr')
f = created_layer.getFeatures(QgsFeatureRequest()).next()
f = next(created_layer.getFeatures(QgsFeatureRequest()))
g = f.geometry()
wkt = g.exportToWkt()
expWkt = 'MultiPoint ((1 2))'
@@ -302,7 +302,7 @@ def testWriteShapefileWithAttributeSubsets(self):
# Open result and check
created_layer = QgsVectorLayer(u'{}|layerid=0'.format(dest_file_name), u'test', u'ogr')
self.assertEqual(created_layer.fields().count(), 4)
f = created_layer.getFeatures(QgsFeatureRequest()).next()
f = next(created_layer.getFeatures(QgsFeatureRequest()))
self.assertEqual(f['id'], 1)
self.assertEqual(f['field1'], 11)
self.assertEqual(f['field2'], 12)
@@ -322,7 +322,7 @@ def testWriteShapefileWithAttributeSubsets(self):
# Open result and check
created_layer = QgsVectorLayer(u'{}|layerid=0'.format(dest_file_name), u'test', u'ogr')
self.assertEqual(created_layer.fields().count(), 2)
f = created_layer.getFeatures(QgsFeatureRequest()).next()
f = next(created_layer.getFeatures(QgsFeatureRequest()))
self.assertEqual(f['field1'], 11)
self.assertEqual(f['field3'], 13)

@@ -344,7 +344,7 @@ def testWriteShapefileWithAttributeSubsets(self):
self.assertEqual(created_layer.fields()[0].name(), 'FID')
# in this case we also check that the geometry exists, to make sure feature has been correctly written
# even without attributes
f = created_layer.getFeatures(QgsFeatureRequest()).next()
f = next(created_layer.getFeatures(QgsFeatureRequest()))
g = f.geometry()
wkt = g.exportToWkt()
expWkt = 'Point (1 2)'

0 comments on commit c268f7e

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