diff --git a/mopidy/config/__init__.py b/mopidy/config/__init__.py index a7153ea2..f68567e7 100644 --- a/mopidy/config/__init__.py +++ b/mopidy/config/__init__.py @@ -167,6 +167,8 @@ def _format(config, comments, schemas, display, disable): continue output.append(b'[%s]' % bytes(schema.name)) for key, value in serialized.items(): + if isinstance(value, types.DeprecatedValue): + continue comment = bytes(comments.get(schema.name, {}).get(key, '')) output.append(b'%s =' % bytes(key)) if value is not None: diff --git a/mopidy/config/schemas.py b/mopidy/config/schemas.py index 67473b88..b026ac2b 100644 --- a/mopidy/config/schemas.py +++ b/mopidy/config/schemas.py @@ -71,11 +71,11 @@ class ConfigSchema(collections.OrderedDict): errors[key] = str(e) for key in self.keys(): - if key not in result and key not in errors: + if isinstance(self[key], types.Deprecated): + result.pop(key, None) + elif key not in result and key not in errors: result[key] = None errors[key] = 'config key not found.' - if isinstance(result[key], types.DeprecatedValue): - del result[key] return result, errors diff --git a/tests/config/schemas_test.py b/tests/config/schemas_test.py index 82ea159b..6eb35ed3 100644 --- a/tests/config/schemas_test.py +++ b/tests/config/schemas_test.py @@ -77,11 +77,10 @@ class ConfigSchemaTest(unittest.TestCase): self.assertIsNone(result['bar']) self.assertIsNone(result['baz']) - def test_deserialize_none_value(self): - self.schema['foo'].deserialize.return_value = types.DeprecatedValue() + def test_deserialize_deprecated_value(self): + self.schema['foo'] = types.Deprecated() result, errors = self.schema.deserialize(self.values) - print result, errors self.assertItemsEqual(['bar', 'baz'], result.keys()) self.assertNotIn('foo', errors)