Пример #1
0
    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)
Пример #2
0
 def test_int(self):
     """
     An non string key should still work.
     """
     self.assertEqual(
         config.get_key(self.config, 1),
         'bar'
     )
Пример #3
0
 def test_dotted(self):
     """
     dotted notation must be supported.
     """
     self.assertEqual(
         config.get_key(self.config, 'foo.bar'),
         self.config['foo']['bar']
     )
Пример #4
0
 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']
     )