Skip to content

Commit

Permalink
Improve some asserts for more meaningful output in case of error
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Dec 20, 2016
1 parent 2f0f6a9 commit 1a64822
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions tests/src/python/test_qgscolorschemeregistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,45 +28,45 @@ def testCreateInstance(self):
def testInstanceHasDefaultScheme(self):
"""Test global color scheme registry has default schemes"""
registry = QgsColorSchemeRegistry.instance()
self.assertTrue(len(registry.schemes()) > 0)
self.assertGreater(len(registry.schemes()), 0)

def testCreateEmpty(self):
"""Test creating an empty color scheme registry"""
registry = QgsColorSchemeRegistry()
self.assertTrue(len(registry.schemes()) == 0)
self.assertGreater(len(registry.schemes()), 0)

def testAddScheme(self):
"""Test adding a scheme to a registry"""
registry = QgsColorSchemeRegistry()
self.assertTrue(len(registry.schemes()) == 0)
self.assertEqual(len(registry.schemes()), 0)
recentScheme = QgsRecentColorScheme()
registry.addColorScheme(recentScheme)
self.assertTrue(len(registry.schemes()) == 1)
self.assertEqual(len(registry.schemes()), 1)

def testAddDefaultScheme(self):
"""Test adding default schemes to a registry"""
registry = QgsColorSchemeRegistry()
self.assertTrue(len(registry.schemes()) == 0)
self.assertEqual(len(registry.schemes()), 0)
registry.addDefaultSchemes()
self.assertTrue(len(registry.schemes()) > 0)
self.assertGreater(len(registry.schemes()), 0)

def testPopulateFromInstance(self):
"""Test adding schemes from global instance"""
registry = QgsColorSchemeRegistry()
self.assertTrue(len(registry.schemes()) == 0)
self.assertEqual(len(registry.schemes()), 0)
registry.populateFromInstance()
self.assertEqual(len(registry.schemes()), len(QgsColorSchemeRegistry.instance().schemes()))

def testRemoveScheme(self):
"""Test removing a scheme from a registry"""
registry = QgsColorSchemeRegistry()
self.assertTrue(len(registry.schemes()) == 0)
self.assertEqual(len(registry.schemes()), 0)
recentScheme = QgsRecentColorScheme()
registry.addColorScheme(recentScheme)
self.assertTrue(len(registry.schemes()) == 1)
self.assertEqual(len(registry.schemes()), 1)
# remove the scheme
registry.removeColorScheme(recentScheme)
self.assertTrue(len(registry.schemes()) == 0)
self.assertEqual(len(registry.schemes()), 0)
# try removing a scheme not in the registry
self.assertFalse(registry.removeColorScheme(recentScheme))

Expand Down
6 changes: 3 additions & 3 deletions tests/src/python/test_qgsexpression.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def tearDown(self):
def testCanBeRegistered(self):
QgsExpression.registerFunction(self.testfun)
index = QgsExpression.functionIndex('testfun')
self.assertTrue(not index == -1)
self.assertNotEqual(index, -1)

def testAutoCountsCorrectArgs(self):
function = self.autocount
Expand All @@ -81,11 +81,11 @@ def testAutoArgsAreExpanded(self):
def testCanUnregisterFunction(self):
QgsExpression.registerFunction(self.testfun)
index = QgsExpression.functionIndex('testfun')
self.assertTrue(not index == -1)
self.assertNotEqual(index, -1)
error = QgsExpression.unregisterFunction('testfun')
self.assertTrue(error)
index = QgsExpression.functionIndex('testfun')
self.assertTrue(index == -1)
self.assertEqual(index, -1)

def testCanEvaluateFunction(self):
QgsExpression.registerFunction(self.testfun)
Expand Down

0 comments on commit 1a64822

Please sign in to comment.