diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2025-02-14 07:31:43 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2025-02-14 07:31:43 (GMT) | 
| commit | f58a0e1138a3a3b8a4cfa237f1fe75a24ea8e2ba (patch) | |
| tree | 3be24d2b261593f7ca11a665d3d1c34975c50d8d /tests | |
| parent | 80428ecdd6411a94cf1248d113535b938fe6dbea (diff) | |
Resolve test schemas dynamically.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/glibext/secstorage.py | 26 | 
1 files changed, 18 insertions, 8 deletions
diff --git a/tests/glibext/secstorage.py b/tests/glibext/secstorage.py index 248b3e3..5b8f680 100644 --- a/tests/glibext/secstorage.py +++ b/tests/glibext/secstorage.py @@ -22,8 +22,6 @@ class TestSecretStorage(ChrysalideTestCase):          subprocess.run([ 'glib-compile-schemas', path ]) -        os.environ['GSETTINGS_SCHEMA_DIR'] = path + ':' + os.environ['GSETTINGS_SCHEMA_DIR'] -      @classmethod      def tearDownClass(cls): @@ -32,8 +30,6 @@ class TestSecretStorage(ChrysalideTestCase):          cls.log('Removing compiled GSettings schema...') -        os.environ['GSETTINGS_SCHEMA_DIR'] = ':'.join(os.environ['GSETTINGS_SCHEMA_DIR'].split(':')[1:]) -          path = os.path.dirname(os.path.realpath(__file__))          filename = os.path.join(path, 'gschemas.compiled') @@ -42,10 +38,24 @@ class TestSecretStorage(ChrysalideTestCase):              os.remove(filename) +    def _get_settings(self, sid): +        """Provide local GSettings instance.""" + +        path = os.path.dirname(os.path.realpath(__file__)) + +        source =  Gio.SettingsSchemaSource.new_from_directory(path, None, True) + +        schema = Gio.SettingsSchemaSource.lookup(source, sid, False) + +        settings = Gio.Settings.new_full(schema, None, None) + +        return settings + +      def testMasterKeyDefinition(self):          """Check for cryptographic parameters for secret storage.""" -        settings = Gio.Settings.new('re.chrysalide.tests.secstorage') +        settings = self._get_settings('re.chrysalide.tests.secstorage')          storage = SecretStorage(settings) @@ -67,7 +77,7 @@ class TestSecretStorage(ChrysalideTestCase):      def testMasterKeyCreation(self):          """Create and update cryptographic parameters for secret storage.""" -        settings = Gio.Settings.new('re.chrysalide.tests.secstorage') +        settings = self._get_settings('re.chrysalide.tests.secstorage')          storage = SecretStorage(settings) @@ -101,9 +111,9 @@ class TestSecretStorage(ChrysalideTestCase):      def testDataEncryption(self): -        """Create and update cryptographic parameters for secret storage.""" +        """Encrypt and decrypt data with the secret storage.""" -        settings = Gio.Settings.new('re.chrysalide.tests.secstorage') +        settings = self._get_settings('re.chrysalide.tests.secstorage')          storage = SecretStorage(settings)  | 
