コード例 #1
0
ファイル: test_valid.py プロジェクト: hkhanna/confit
 def test_other_type_as_template(self):
     class MyClass(object):
         pass
     typ = confit.as_template(MyClass)
     self.assertIsInstance(typ, confit.TypeTemplate)
     self.assertEqual(typ.typ, MyClass)
     self.assertEqual(typ.default, confit.REQUIRED)
コード例 #2
0
    def test_other_type_as_template(self):
        class MyClass(object):
            pass

        typ = confit.as_template(MyClass)
        self.assertIsInstance(typ, confit.TypeTemplate)
        self.assertEqual(typ.typ, MyClass)
        self.assertEqual(typ.default, confit.REQUIRED)
コード例 #3
0
 def test_nested_dict_as_template(self):
     typ = confit.as_template({'outer': {'inner': 2}})
     self.assertIsInstance(typ, confit.MappingTemplate)
     self.assertIsInstance(typ.subtemplates['outer'],
                           confit.MappingTemplate)
     self.assertIsInstance(typ.subtemplates['outer'].subtemplates['inner'],
                           confit.Integer)
     self.assertEqual(
         typ.subtemplates['outer'].subtemplates['inner'].default, 2)
コード例 #4
0
ファイル: test_valid.py プロジェクト: hkhanna/confit
 def test_nested_dict_as_template(self):
     typ = confit.as_template({'outer': {'inner': 2}})
     self.assertIsInstance(typ, confit.MappingTemplate)
     self.assertIsInstance(typ.subtemplates['outer'],
                           confit.MappingTemplate)
     self.assertIsInstance(typ.subtemplates['outer'].subtemplates['inner'],
                           confit.Integer)
     self.assertEqual(typ.subtemplates['outer'].subtemplates['inner']
                      .default, 2)
コード例 #5
0
 def test_float_type_as_tempalte(self):
     typ = confit.as_template(float)
     self.assertIsInstance(typ, confit.Number)
     self.assertEqual(typ.default, confit.REQUIRED)
コード例 #6
0
 def test_basestring_as_template(self):
     typ = confit.as_template(basestring)
     self.assertIsInstance(typ, confit.String)
     self.assertEqual(typ.default, confit.REQUIRED)
コード例 #7
0
 def test_dict_as_template(self):
     typ = confit.as_template({'key': 9})
     self.assertIsInstance(typ, confit.MappingTemplate)
     self.assertIsInstance(typ.subtemplates['key'], confit.Integer)
     self.assertEqual(typ.subtemplates['key'].default, 9)
コード例 #8
0
ファイル: test_valid.py プロジェクト: hkhanna/confit
 def test_dict_as_template(self):
     typ = confit.as_template({'key': 9})
     self.assertIsInstance(typ, confit.MappingTemplate)
     self.assertIsInstance(typ.subtemplates['key'], confit.Integer)
     self.assertEqual(typ.subtemplates['key'].default, 9)
コード例 #9
0
 def test_unicode_type_as_template(self):
     typ = confit.as_template(unicode)
     self.assertIsInstance(typ, confit.String)
     self.assertEqual(typ.default, confit.REQUIRED)
コード例 #10
0
 def test_set_type_as_template(self):
     typ = confit.as_template(set)
     self.assertIsInstance(typ, confit.TypeTemplate)
     self.assertEqual(typ.typ, set)
     self.assertEqual(typ.default, confit.REQUIRED)
コード例 #11
0
 def test_plain_int_as_template(self):
     typ = confit.as_template(int)
     self.assertIsInstance(typ, confit.Integer)
     self.assertEqual(typ.default, confit.REQUIRED)
コード例 #12
0
ファイル: test_valid.py プロジェクト: hkhanna/confit
 def test_list_as_template(self):
     typ = confit.as_template(list())
     self.assertIsInstance(typ, confit.OneOf)
     self.assertEqual(typ.default, confit.REQUIRED)
コード例 #13
0
 def test_dict_type_as_template(self):
     typ = confit.as_template(dict)
     self.assertIsInstance(typ, confit.TypeTemplate)
     self.assertEqual(typ.typ, collections.Mapping)
     self.assertEqual(typ.default, confit.REQUIRED)
コード例 #14
0
ファイル: test_valid.py プロジェクト: hkhanna/confit
 def test_set_type_as_template(self):
     typ = confit.as_template(set)
     self.assertIsInstance(typ, confit.TypeTemplate)
     self.assertEqual(typ.typ, set)
     self.assertEqual(typ.default, confit.REQUIRED)
コード例 #15
0
 def test_list_as_template(self):
     typ = confit.as_template(list())
     self.assertIsInstance(typ, confit.OneOf)
     self.assertEqual(typ.default, confit.REQUIRED)
コード例 #16
0
ファイル: test_valid.py プロジェクト: hkhanna/confit
 def test_list_type_as_template(self):
     typ = confit.as_template(list)
     self.assertIsInstance(typ, confit.TypeTemplate)
     self.assertEqual(typ.typ, collections.Sequence)
     self.assertEqual(typ.default, confit.REQUIRED)
コード例 #17
0
ファイル: test_valid.py プロジェクト: hkhanna/confit
 def test_dict_type_as_template(self):
     typ = confit.as_template(dict)
     self.assertIsInstance(typ, confit.TypeTemplate)
     self.assertEqual(typ.typ, collections.Mapping)
     self.assertEqual(typ.default, confit.REQUIRED)
コード例 #18
0
ファイル: test_valid.py プロジェクト: hkhanna/confit
 def test_none_as_template(self):
     typ = confit.as_template(None)
     self.assertIs(type(typ), confit.Template)
     self.assertEqual(typ.default, confit.REQUIRED)
コード例 #19
0
ファイル: test_valid.py プロジェクト: hkhanna/confit
 def test_float_type_as_tempalte(self):
     typ = confit.as_template(float)
     self.assertIsInstance(typ, confit.Number)
     self.assertEqual(typ.default, confit.REQUIRED)
コード例 #20
0
ファイル: test_valid.py プロジェクト: hkhanna/confit
 def test_set_as_template(self):
     typ = confit.as_template(set())
     self.assertIsInstance(typ, confit.Choice)
コード例 #21
0
 def test_set_as_template(self):
     typ = confit.as_template(set())
     self.assertIsInstance(typ, confit.Choice)
コード例 #22
0
ファイル: test_valid.py プロジェクト: hkhanna/confit
 def test_plain_int_as_template(self):
     typ = confit.as_template(int)
     self.assertIsInstance(typ, confit.Integer)
     self.assertEqual(typ.default, confit.REQUIRED)
コード例 #23
0
 def test_none_as_template(self):
     typ = confit.as_template(None)
     self.assertIs(type(typ), confit.Template)
     self.assertEqual(typ.default, confit.REQUIRED)
コード例 #24
0
ファイル: test_valid.py プロジェクト: hkhanna/confit
 def test_concrete_int_as_template(self):
     typ = confit.as_template(2)
     self.assertIsInstance(typ, confit.Integer)
     self.assertEqual(typ.default, 2)
コード例 #25
0
 def test_list_type_as_template(self):
     typ = confit.as_template(list)
     self.assertIsInstance(typ, confit.TypeTemplate)
     self.assertEqual(typ.typ, collections.Sequence)
     self.assertEqual(typ.default, confit.REQUIRED)
コード例 #26
0
ファイル: test_valid.py プロジェクト: hkhanna/confit
 def test_plain_string_as_template(self):
     typ = confit.as_template(str)
     self.assertIsInstance(typ, confit.String)
     self.assertEqual(typ.default, confit.REQUIRED)
コード例 #27
0
ファイル: test_valid.py プロジェクト: hkhanna/confit
 def test_concrete_string_as_template(self):
     typ = confit.as_template('foo')
     self.assertIsInstance(typ, confit.String)
     self.assertEqual(typ.default, 'foo')
コード例 #28
0
 def test_concrete_string_as_template(self):
     typ = confit.as_template('foo')
     self.assertIsInstance(typ, confit.String)
     self.assertEqual(typ.default, 'foo')
コード例 #29
0
 def test_concrete_int_as_template(self):
     typ = confit.as_template(2)
     self.assertIsInstance(typ, confit.Integer)
     self.assertEqual(typ.default, 2)
コード例 #30
0
ファイル: test_valid.py プロジェクト: hkhanna/confit
 def test_unicode_type_as_template(self):
     typ = confit.as_template(unicode)
     self.assertIsInstance(typ, confit.String)
     self.assertEqual(typ.default, confit.REQUIRED)