Skip to content
Permalink
Browse files

Manual next fixes

  • Loading branch information
m-kuhn committed Apr 15, 2016
1 parent c268f7e commit 3e300f296693547bf7a93ffd8afadd695a5d0610
Showing with 11 additions and 11 deletions.
  1. +2 −2 tests/src/python/test_qgsvectorlayer.py
  2. +9 −9 tests/src/python/test_syntactic_sugar.py
@@ -971,12 +971,12 @@ def test_ExpressionField(self):

idx = layer.addExpressionField('5', QgsField('test', QVariant.LongLong))

self.assertEquals(layer.getFeatures().next()[idx], 5)
self.assertEquals(next(layer.getFeatures())[idx], 5)
self.assertEquals(layer.pendingFields().count(), cnt + 1)

layer.updateExpressionField(idx, '9')

self.assertEquals(layer.getFeatures().next()[idx], 9)
self.assertEquals(next(layer.getFeatures())[idx], 9)

layer.removeExpressionField(idx)

@@ -32,25 +32,25 @@ def testEdit(self):
ml = QgsVectorLayer("Point?crs=epsg:4236&field=id:integer&field=value:double",
"test_data", "memory")
# Data as list of x, y, id, value
assert ml.isValid()
self.assertTrue(ml.isValid())
fields = ml.fields()

# Check insert
with edit(ml):
feat = QgsFeature(fields)
feat['id'] = 1
feat['value'] = 0.9
assert ml.addFeature(feat)
self.assertTrue(ml.addFeature(feat))

assert ml.dataProvider().getFeatures().next()['value'] == 0.9
self.assertEqual(next(ml.dataProvider().getFeatures())['value'], 0.9)

# Check update
with edit(ml):
f = next(ml.getFeatures())
f['value'] = 9.9
assert ml.updateFeature(f)
self.assertTrue(ml.updateFeature(f))

assert ml.dataProvider().getFeatures().next()['value'] == 9.9
self.assertEqual(next(ml.dataProvider().getFeatures())['value'], 9.9)

# Check for rollBack after exceptions
with self.assertRaises(NameError):
@@ -59,16 +59,16 @@ def testEdit(self):
f['value'] = 3.8
crashycrash() # NOQA

assert ml.dataProvider().getFeatures().next()['value'] == 9.9
assert ml.getFeatures().next()['value'] == 9.9
self.assertEqual(next(ml.dataProvider().getFeatures())['value'], 9.9)
self.assertEqual(next(ml.getFeatures())['value'], 9.9)

# Check for `as`
with edit(ml) as l:
f = next(l.getFeatures())
f['value'] = 10
assert l.updateFeature(f)
self.assertTrue(l.updateFeature(f))

assert ml.dataProvider().getFeatures().next()['value'] == 10
self.assertEqual(next(ml.dataProvider().getFeatures())['value'], 10)

# Check that we get a QgsEditError exception when the commit fails
with self.assertRaises(QgsEditError):

0 comments on commit 3e300f2

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