Skip to content
Permalink
Browse files

Improve some asserts for more meaningful output in case of error

  • Loading branch information
m-kuhn committed Dec 20, 2016
1 parent 2f0f6a9 commit 1a648229e8406ddf9c81e55211ce4b4de855beff
Showing with 13 additions and 13 deletions.
  1. +10 −10 tests/src/python/test_qgscolorschemeregistry.py
  2. +3 −3 tests/src/python/test_qgsexpression.py
@@ -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))

@@ -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
@@ -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)

0 comments on commit 1a64822

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