def test_missing_key(self): """ Ensure that the default is returned when the key is missing from the config """ with self.assertRaises(KeyError): config.get_key(self.config, 'bar') missing = object() ret = config.get_key(self.config, 'bar', missing) self.assertIs(ret, missing)
def test_int(self): """ An non string key should still work. """ self.assertEqual( config.get_key(self.config, 1), 'bar' )
def test_dotted(self): """ dotted notation must be supported. """ self.assertEqual( config.get_key(self.config, 'foo.bar'), self.config['foo']['bar'] )
def test_not_dotted(self): """ A key on the first layer returns the correct value """ self.assertEqual( config.get_key(self.config, 'foo'), self.config['foo'] )