# HG changeset patch # User Jeff Hammel # Date 1332806702 25200 # Node ID b27a7cb2dd5bb46c4baab3c5f5b2b25d516e95d6 # Parent fadcc6ab51d40cdf424da51d7650e65fc4e0723a stub test for configuration providers diff -r fadcc6ab51d4 -r b27a7cb2dd5b configuration/config.py --- a/configuration/config.py Mon Mar 26 17:00:12 2012 -0700 +++ b/configuration/config.py Mon Mar 26 17:05:02 2012 -0700 @@ -59,11 +59,11 @@ def _write(self, fp, config): fp.write(json.dumps(config), indent=self.indent, sort_keys=True) # TODO: could use templates to get order down, etc - configuration_providers.append(JSON) + configuration_providers.append(JSON()) if yaml: class YAML(object): - extensions = ['yml'] + extensions = ['yml', 'yaml'] def read(self, filename): f = file(filename) config = yaml.load(f) @@ -73,7 +73,9 @@ fp.write(yaml.dump(config)) # TODO: could use templates to get order down, etc - configuration_providers.append(YAML) + configuration_providers.append(YAML()) + +__all__.extend([i.__class__.__name__ for i in configuration_providers]) ### plugins for option types ### TODO: this could use a bit of thought @@ -275,4 +277,3 @@ if not format: extension = os.path.splitext(filename)[-1] - diff -r fadcc6ab51d4 -r b27a7cb2dd5b tests/unit.py --- a/tests/unit.py Mon Mar 26 17:00:12 2012 -0700 +++ b/tests/unit.py Mon Mar 26 17:05:02 2012 -0700 @@ -4,6 +4,7 @@ unit tests """ +import configuration import os import sys import unittest @@ -36,6 +37,13 @@ def test_configuration_providers(self): """test file-based configuration providers""" + # require json/simplejson and pyyaml to be installed + + example = ExampleConfiguration() + + # see what providers you got + json_provider = example.configuration_provider('json') + self.assertTrue(isinstance(json_provider, configuration.JSON)) if __name__ == '__main__': unittest.main()