How to use the confuse.as_template function in confuse

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_other_type_as_template(self):
        class MyClass(object):
            pass
        typ = confuse.as_template(MyClass)
        self.assertIsInstance(typ, confuse.TypeTemplate)
        self.assertEqual(typ.typ, MyClass)
        self.assertEqual(typ.default, confuse.REQUIRED)
github beetbox / confuse / test / test_valid.py View on Github external
def test_dict_as_template(self):
        typ = confuse.as_template({'key': 9})
        self.assertIsInstance(typ, confuse.MappingTemplate)
        self.assertIsInstance(typ.subtemplates['key'], confuse.Integer)
        self.assertEqual(typ.subtemplates['key'].default, 9)
github beetbox / confuse / test / test_valid.py View on Github external
def test_concrete_int_as_template(self):
        typ = confuse.as_template(2)
        self.assertIsInstance(typ, confuse.Integer)
        self.assertEqual(typ.default, 2)
github beetbox / confuse / test / test_valid.py View on Github external
def test_concrete_float_as_template(self):
        typ = confuse.as_template(2.)
        self.assertIsInstance(typ, confuse.Number)
        self.assertEqual(typ.default, 2.)
github beetbox / confuse / test / test_valid.py View on Github external
def test_concrete_string_as_template(self):
        typ = confuse.as_template('foo')
        self.assertIsInstance(typ, confuse.String)
        self.assertEqual(typ.default, 'foo')
github beetbox / confuse / test / test_valid.py View on Github external
def test_list_as_template(self):
        typ = confuse.as_template(list())
        self.assertIsInstance(typ, confuse.OneOf)
        self.assertEqual(typ.default, confuse.REQUIRED)
github beetbox / confuse / test / test_valid.py View on Github external
def test_dict_type_as_template(self):
        typ = confuse.as_template(dict)
        self.assertIsInstance(typ, confuse.TypeTemplate)
        self.assertEqual(typ.typ, Mapping)
        self.assertEqual(typ.default, confuse.REQUIRED)
github beetbox / confuse / test / test_valid.py View on Github external
def test_unicode_type_as_template(self):
        typ = confuse.as_template(unicode)  # noqa ignore=F821
        self.assertIsInstance(typ, confuse.String)
        self.assertEqual(typ.default, confuse.REQUIRED)
github beetbox / confuse / test / test_valid.py View on Github external
def test_none_as_template(self):
        typ = confuse.as_template(None)
        self.assertIs(type(typ), confuse.Template)
        self.assertEqual(typ.default, confuse.REQUIRED)
github beetbox / confuse / test / test_valid.py View on Github external
def test_set_type_as_template(self):
        typ = confuse.as_template(set)
        self.assertIsInstance(typ, confuse.TypeTemplate)
        self.assertEqual(typ.typ, set)
        self.assertEqual(typ.default, confuse.REQUIRED)