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))
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))
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'))
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'))