Skip to content
Permalink
Browse files

Replace calls to deprecated `assertEquals` method

  • Loading branch information
m-kuhn committed May 3, 2016
1 parent 4335a77 commit c1687abc80e794c39744986509cc5b5d2f7237ae
@@ -190,39 +190,39 @@ class ParameterFileTest(unittest.TestCase):
def testSetValue(self):
parameter = ParameterFile('myName', 'myDesc')
self.assertTrue(parameter.setValue('myFile.png'))
self.assertEquals(parameter.value, 'myFile.png')
self.assertEqual(parameter.value, 'myFile.png')

def testOptional(self):
optionalParameter = ParameterFile('myName', 'myDesc', optional=True)
self.assertTrue(optionalParameter.setValue('myFile.png'))
self.assertEquals(optionalParameter.value, 'myFile.png')
self.assertEqual(optionalParameter.value, 'myFile.png')

self.assertTrue(optionalParameter.setValue(""))
self.assertEquals(optionalParameter.value, '')
self.assertEqual(optionalParameter.value, '')

self.assertTrue(optionalParameter.setValue(None))
self.assertEquals(optionalParameter.value, None)
self.assertEqual(optionalParameter.value, None)

requiredParameter = ParameterFile('myName', 'myDesc', optional=False)
self.assertTrue(requiredParameter.setValue('myFile.png'))
self.assertEquals(requiredParameter.value, 'myFile.png')
self.assertEqual(requiredParameter.value, 'myFile.png')

self.assertFalse(requiredParameter.setValue(''))
self.assertEquals(requiredParameter.value, 'myFile.png')
self.assertEqual(requiredParameter.value, 'myFile.png')

self.assertFalse(requiredParameter.setValue(' '))
self.assertEquals(requiredParameter.value, 'myFile.png')
self.assertEqual(requiredParameter.value, 'myFile.png')

self.assertFalse(requiredParameter.setValue(None))
self.assertEquals(requiredParameter.value, 'myFile.png')
self.assertEqual(requiredParameter.value, 'myFile.png')

def testSetValueWithExtension(self):
parameter = ParameterFile('myName', 'myDesc', ext="png")
self.assertTrue(parameter.setValue('myFile.png'))
self.assertEquals(parameter.value, 'myFile.png')
self.assertEqual(parameter.value, 'myFile.png')

self.assertFalse(parameter.setValue('myFile.bmp'))
self.assertEquals(parameter.value, 'myFile.png')
self.assertEqual(parameter.value, 'myFile.png')

def testGetValueAsCommandLineParameter(self):
parameter = ParameterFile('myName', 'myDesc')
@@ -237,13 +237,13 @@ def testTableToString(self):
['a0', 'a1', 'a2'],
['b0', 'b1', 'b2']
]
self.assertEquals(ParameterFixedTable.tableToString(table), 'a0,a1,a2,b0,b1,b2')
self.assertEqual(ParameterFixedTable.tableToString(table), 'a0,a1,a2,b0,b1,b2')

table = [['a0']]
self.assertEquals(ParameterFixedTable.tableToString(table), 'a0')
self.assertEqual(ParameterFixedTable.tableToString(table), 'a0')

table = [[]]
self.assertEquals(ParameterFixedTable.tableToString(table), '')
self.assertEqual(ParameterFixedTable.tableToString(table), '')

def testSetStringValue(self):
parameter = ParameterFixedTable('myName', 'myDesc')
@@ -345,7 +345,7 @@ class ParameterNumberTest(unittest.TestCase):
def testSetValue(self):
parameter = ParameterNumber('myName', 'myDescription')
self.assertTrue(parameter.setValue(5))
self.assertEquals(parameter.value, 5)
self.assertEqual(parameter.value, 5)

def testSetValueOnlyValidNumbers(self):
parameter = ParameterNumber('myName', 'myDescription')
@@ -82,7 +82,7 @@ def assertLayersEqual(self, layer_expected, layer_result, **kwargs):
geom1 = feats[1].geometry().geometry().asWkt(precision)
else:
geom1 = None
_TestCase.assertEquals(
_TestCase.assertEqual(
self,
geom0,
geom1,
@@ -258,77 +258,77 @@ def testOrderByCompiled(self):
def runOrderByTests(self):
request = QgsFeatureRequest().addOrderBy('cnt')
values = [f['cnt'] for f in self.provider.getFeatures(request)]
self.assertEquals(values, [-200, 100, 200, 300, 400])
self.assertEqual(values, [-200, 100, 200, 300, 400])

request = QgsFeatureRequest().addOrderBy('cnt', False)
values = [f['cnt'] for f in self.provider.getFeatures(request)]
self.assertEquals(values, [400, 300, 200, 100, -200])
self.assertEqual(values, [400, 300, 200, 100, -200])

request = QgsFeatureRequest().addOrderBy('name')
values = [f['name'] for f in self.provider.getFeatures(request)]
self.assertEquals(values, ['Apple', 'Honey', 'Orange', 'Pear', NULL])
self.assertEqual(values, ['Apple', 'Honey', 'Orange', 'Pear', NULL])

request = QgsFeatureRequest().addOrderBy('name', True, True)
values = [f['name'] for f in self.provider.getFeatures(request)]
self.assertEquals(values, [NULL, 'Apple', 'Honey', 'Orange', 'Pear'])
self.assertEqual(values, [NULL, 'Apple', 'Honey', 'Orange', 'Pear'])

request = QgsFeatureRequest().addOrderBy('name', False)
values = [f['name'] for f in self.provider.getFeatures(request)]
self.assertEquals(values, [NULL, 'Pear', 'Orange', 'Honey', 'Apple'])
self.assertEqual(values, [NULL, 'Pear', 'Orange', 'Honey', 'Apple'])

request = QgsFeatureRequest().addOrderBy('name', False, False)
values = [f['name'] for f in self.provider.getFeatures(request)]
self.assertEquals(values, ['Pear', 'Orange', 'Honey', 'Apple', NULL])
self.assertEqual(values, ['Pear', 'Orange', 'Honey', 'Apple', NULL])

# Case sensitivity
request = QgsFeatureRequest().addOrderBy('name2')
values = [f['name2'] for f in self.provider.getFeatures(request)]
self.assertEquals(values, ['Apple', 'Honey', 'NuLl', 'oranGe', 'PEaR'])
self.assertEqual(values, ['Apple', 'Honey', 'NuLl', 'oranGe', 'PEaR'])

# Combination with LIMIT
request = QgsFeatureRequest().addOrderBy('pk', False).setLimit(2)
values = [f['pk'] for f in self.provider.getFeatures(request)]
self.assertEquals(values, [5, 4])
self.assertEqual(values, [5, 4])

# A slightly more complex expression
request = QgsFeatureRequest().addOrderBy('pk*2', False)
values = [f['pk'] for f in self.provider.getFeatures(request)]
self.assertEquals(values, [5, 4, 3, 2, 1])
self.assertEqual(values, [5, 4, 3, 2, 1])

# Order reversing expression
request = QgsFeatureRequest().addOrderBy('pk*-1', False)
values = [f['pk'] for f in self.provider.getFeatures(request)]
self.assertEquals(values, [1, 2, 3, 4, 5])
self.assertEqual(values, [1, 2, 3, 4, 5])

# Type dependent expression
request = QgsFeatureRequest().addOrderBy('num_char*2', False)
values = [f['pk'] for f in self.provider.getFeatures(request)]
self.assertEquals(values, [5, 4, 3, 2, 1])
self.assertEqual(values, [5, 4, 3, 2, 1])

# Order by guaranteed to fail
request = QgsFeatureRequest().addOrderBy('not a valid expression*', False)
values = [f['pk'] for f in self.provider.getFeatures(request)]
self.assertEquals(set(values), set([5, 4, 3, 2, 1]))
self.assertEqual(set(values), set([5, 4, 3, 2, 1]))

# Multiple order bys and boolean
request = QgsFeatureRequest().addOrderBy('pk > 2').addOrderBy('pk', False)
values = [f['pk'] for f in self.provider.getFeatures(request)]
self.assertEquals(values, [2, 1, 5, 4, 3])
self.assertEqual(values, [2, 1, 5, 4, 3])

# Multiple order bys, one bad, and a limit
request = QgsFeatureRequest().addOrderBy('pk', False).addOrderBy('not a valid expression*', False).setLimit(2)
values = [f['pk'] for f in self.provider.getFeatures(request)]
self.assertEquals(values, [5, 4])
self.assertEqual(values, [5, 4])

# Bad expression first
request = QgsFeatureRequest().addOrderBy('not a valid expression*', False).addOrderBy('pk', False).setLimit(2)
values = [f['pk'] for f in self.provider.getFeatures(request)]
self.assertEquals(values, [5, 4])
self.assertEqual(values, [5, 4])

# Combination with subset of attributes
request = QgsFeatureRequest().addOrderBy('num_char', False).setSubsetOfAttributes(['pk'], self.vl.fields())
values = [f['pk'] for f in self.vl.getFeatures(request)]
self.assertEquals(values, [5, 4, 3, 2, 1])
self.assertEqual(values, [5, 4, 3, 2, 1])

def testGetFeaturesFidTests(self):
fids = [f.id() for f in self.provider.getFeatures()]
@@ -121,8 +121,8 @@ def testRepack(self):

ids = [f.id() for f in vl.getFeatures(QgsFeatureRequest().setFilterExpression('pk=1'))]
vl.setSelectedFeatures(ids)
self.assertEquals(vl.selectedFeaturesIds(), ids)
self.assertEquals(vl.pendingFeatureCount(), 5)
self.assertEqual(vl.selectedFeaturesIds(), ids)
self.assertEqual(vl.pendingFeatureCount(), 5)
self.assertTrue(vl.startEditing())
self.assertTrue(vl.deleteFeature(3))
self.assertTrue(vl.commitChanges())

0 comments on commit c1687ab

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