Skip to content
Browse files
Add registry keepreference test
  • Loading branch information
m-kuhn committed Feb 6, 2019
1 parent 89ea819 commit b2aed603f1dc52040ee9940facd7ccedf6208317
Showing with 29 additions and 1 deletion.
  1. +29 −1 tests/src/python/
@@ -15,7 +15,7 @@
import qgis # NOQA

from qgis.testing import start_app, unittest
from qgis.core import QgsColorSchemeRegistry, QgsRecentColorScheme, QgsApplication
from qgis.core import QgsColorSchemeRegistry, QgsRecentColorScheme, QgsApplication, QgsColorScheme


@@ -72,6 +72,34 @@ def testRemoveScheme(self):
# try removing a scheme not in the registry

def testOwnership(self):
Test that registered color schemes do not require that a reference to them is kept.
They should be parented to the registry (on transfer) and even if there's no reference
to the registry around (see the `del` below) this childship should continue to exist.
class TestColorScheme(QgsColorScheme):

def schemeName(self):
return "TestScheme"

def fetchColors(self, context, baseColors):
return None

def clone(self):
return TestColorScheme()

def flags(self):
return 1

reg = QgsApplication.instance().colorSchemeRegistry()
del reg

reg = QgsApplication.instance().colorSchemeRegistry()

self.assertIn('TestScheme', [scheme.schemeName() for scheme in reg.schemes()])

if __name__ == "__main__":

0 comments on commit b2aed60

Please sign in to comment.