How to use confuse - 10 common examples

To help you get started, we’ve selected a few confuse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github beetbox / confuse / test / test_valid.py View on Github external
def test_filename_relative_to_sibling_needs_siblings(self):
        config = _root({'foo': 'bar'})
        with self.assertRaises(confuse.ConfigTemplateError):
            config['foo'].get(confuse.Filename(relative_to='bar'))
github beetbox / confuse / test / test_valid.py View on Github external
def test_filename_with_file_source(self):
        source = confuse.ConfigSource({'foo': 'foo/bar'},
                                      filename='/baz/config.yaml')
        config = _root(source)
        config.config_dir = lambda: '/config/path'
        valid = config['foo'].get(confuse.Filename())
        self.assertEqual(valid, os.path.realpath('/config/path/foo/bar'))
github beetbox / confuse / test / test_valid.py View on Github external
def test_default_none(self):
        config = _root({})
        valid = config['foo'].get(confuse.Filename(None))
        self.assertEqual(valid, None)
github beetbox / confuse / test / test_valid.py View on Github external
def test_missing_required_value(self):
        config = _root({})
        with self.assertRaises(confuse.NotFoundError):
            config['foo'].get(confuse.Filename())
github beetbox / confuse / test / test_valid.py View on Github external
def test_filename_relative_to_sibling(self):
        config = _root({'foo': '/', 'bar': 'baz'})
        valid = config.get({
            'foo': confuse.Filename(),
            'bar': confuse.Filename(relative_to='foo')
        })
        self.assertEqual(valid.foo, os.path.realpath('/'))
        self.assertEqual(valid.bar, os.path.realpath('/baz'))
github beetbox / confuse / test / test_valid.py View on Github external
def test_filename_relative_to_sibling(self):
        config = _root({'foo': '/', 'bar': 'baz'})
        valid = config.get({
            'foo': confuse.Filename(),
            'bar': confuse.Filename(relative_to='foo')
        })
        self.assertEqual(valid.foo, os.path.realpath('/'))
        self.assertEqual(valid.bar, os.path.realpath('/baz'))
github beetbox / confuse / test / test_valid.py View on Github external
def test_filename_relative_to_sibling_with_recursion(self):
        config = _root({'foo': '/', 'bar': 'r', 'baz': 'z'})
        with self.assertRaises(confuse.ConfigTemplateError):
            config.get({
                'foo': confuse.Filename(relative_to='bar'),
                'bar': confuse.Filename(relative_to='baz'),
                'baz': confuse.Filename(relative_to='foo')
            })
github beetbox / confuse / test / test_valid.py View on Github external
def test_missing_required_value_raises_error_on_validate(self):
        config = _root({})
        with self.assertRaises(confuse.NotFoundError):
            config.get({'foo': confuse.Integer()})
github beetbox / confuse / test / test_valid.py View on Github external
def test_validate_first_good_choice_in_list(self):
        config = _root({'foo': 3.14})
        valid = config['foo'].get(confuse.OneOf([
            confuse.Integer(),
            confuse.Number(),
        ]))
        self.assertEqual(valid, 3)
github beetbox / confuse / test / test_valid.py View on Github external
def test_validate_no_choice_in_list(self):
        config = _root({'foo': None})
        with self.assertRaises(confuse.ConfigValueError):
            config['foo'].get(confuse.OneOf([
                confuse.String(),
                confuse.Integer(),
            ]))