changeset 48:84fb8ad5ba81

ensure that missing values raise the correct exception
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 27 Mar 2012 12:50:16 -0700
parents 7abea9a6fa16
children 09fbc09455d4
files configuration/config.py tests/unit.py
diffstat 2 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/configuration/config.py	Tue Mar 27 12:32:15 2012 -0700
+++ b/configuration/config.py	Tue Mar 27 12:50:16 2012 -0700
@@ -22,7 +22,7 @@
 except ImportError:
     yaml = None
 
-__all__ = ['Configuration', 'configuration_providers', 'types', 'MissingValueException', 'ConfigurationProviderException', 'ConfigurationOption']
+__all__ = ['Configuration', 'configuration_providers', 'types', 'MissingValueException', 'ConfigurationProviderException', 'TypeCastException', 'ConfigurationOption']
 
 ### exceptions
 
--- a/tests/unit.py	Tue Mar 27 12:32:15 2012 -0700
+++ b/tests/unit.py	Tue Mar 27 12:50:16 2012 -0700
@@ -73,6 +73,18 @@
         if os.path.exists(filename):
             os.remove(filename)
 
+    def test_missing_values(self):
+        """ensure that Configuration raises a missing value exception"""
+
+        example = ExampleConfiguration()
+
+        exception = None
+        try:
+            example.parse(args=[])
+        except Exception, exception:
+            pass
+        self.assertTrue(isinstance(exception, configuration.TypeCastException))
+
     def test_required(self):
         """ensure you have to have required values"""