Example #1
0
 def test_cast_get_method(self):
     """Ensure that the get method can cast"""
     envdict = EnvDict({'DEBUG': '1'})
     self.assertEqual(True, envdict.get('DEBUG', cast=bool))
     self.assertEqual(True, envdict.get('MISSING', True, cast=bool))
     # If the key is missing the default should not be cast
     self.assertEqual('True', envdict.get('MISSING', 'True', cast=bool))
Example #2
0
 def test_cast_get_method(self):
     """Ensure that the get method can cast"""
     envdict = EnvDict({'DEBUG': '1'})
     self.assertEqual(True, envdict.get('DEBUG', cast=bool))
     self.assertEqual(True, envdict.get('MISSING', True, cast=bool))
     # If the key is missing the default should not be cast
     self.assertEqual('True', envdict.get('MISSING', 'True', cast=bool))
Example #3
0
 def test_update_casts(self):
     """Update the cast functions on init"""
     envdict = EnvDict({'DEBUG': '1'}, casts={'mycast': Decimal})
     self.assertEqual(envdict.get('DEBUG', cast='mycast'), Decimal('1'))
Example #4
0
 def test_update_casts(self):
     """Update the cast functions on init"""
     envdict = EnvDict({'DEBUG': '1'}, casts={'mycast': Decimal})
     self.assertEqual(envdict.get('DEBUG', cast='mycast'), Decimal('1'))