示例#1
0
 def test_unknown_dict(self):
     """Test type parsing with a dict without keytype."""
     data = self._yaml("type: Dict")
     with pytest.raises(ValueError,
                        match="Invalid node for test while "
                        "reading 'keytype': 'Dict'"):
         configdata._parse_yaml_type('test', data)
示例#2
0
 def test_invalid_node(self):
     """Test type parsing with invalid node type."""
     data = self._yaml("type: 42")
     with pytest.raises(ValueError,
                        match="Invalid node for test while "
                        "reading type: 42"):
         configdata._parse_yaml_type('test', data)
示例#3
0
 def test_unknown_args(self):
     """Test type parsing with unknown type arguments."""
     data = self._yaml("""
         type:
           name: Int
           answer: 42
     """)
     with pytest.raises(TypeError, match="Error while creating Int"):
         configdata._parse_yaml_type('test', data)
示例#4
0
 def test_unknown_args(self):
     """Test type parsing with unknown type arguments."""
     data = self._yaml("""
         type:
           name: Int
           answer: 42
     """)
     with pytest.raises(TypeError, match="Error while creating Int"):
         configdata._parse_yaml_type('test', data)
示例#5
0
 def test_complex(self):
     """Test type parsing with arguments."""
     data = self._yaml("""
         type:
           name: String
           minlen: 2
     """)
     typ = configdata._parse_yaml_type('test', data)
     assert isinstance(typ, configtypes.String)
     assert not typ.none_ok
     assert typ.minlen == 2
示例#6
0
 def test_complex(self):
     """Test type parsing with arguments."""
     data = self._yaml("""
         type:
           name: String
           minlen: 2
     """)
     typ = configdata._parse_yaml_type('test', data)
     assert isinstance(typ, configtypes.String)
     assert not typ.none_ok
     assert typ.minlen == 2
示例#7
0
 def test_list(self):
     """Test type parsing with a list and subtypes."""
     data = self._yaml("""
         type:
           name: List
           valtype: String
     """)
     typ = configdata._parse_yaml_type('test', data)
     assert isinstance(typ, configtypes.List)
     assert isinstance(typ.valtype, configtypes.String)
     assert not typ.none_ok
     assert not typ.valtype.none_ok
示例#8
0
 def test_list(self):
     """Test type parsing with a list and subtypes."""
     data = self._yaml("""
         type:
           name: List
           valtype: String
     """)
     typ = configdata._parse_yaml_type('test', data)
     assert isinstance(typ, configtypes.List)
     assert isinstance(typ.valtype, configtypes.String)
     assert not typ.none_ok
     assert not typ.valtype.none_ok
示例#9
0
 def test_dict(self):
     """Test type parsing with a dict and subtypes."""
     data = self._yaml("""
         type:
           name: Dict
           keytype: String
           valtype:
             name: Int
             minval: 10
     """)
     typ = configdata._parse_yaml_type('test', data)
     assert isinstance(typ, configtypes.Dict)
     assert isinstance(typ.keytype, configtypes.String)
     assert isinstance(typ.valtype, configtypes.Int)
     assert not typ.none_ok
     assert typ.valtype.minval == 10
示例#10
0
 def test_dict(self):
     """Test type parsing with a dict and subtypes."""
     data = self._yaml("""
         type:
           name: Dict
           keytype: String
           valtype:
             name: Int
             minval: 10
     """)
     typ = configdata._parse_yaml_type('test', data)
     assert isinstance(typ, configtypes.Dict)
     assert isinstance(typ.keytype, configtypes.String)
     assert isinstance(typ.valtype, configtypes.Int)
     assert not typ.none_ok
     assert typ.valtype.minval == 10
示例#11
0
 def test_unknown_type(self):
     """Test type parsing with type which doesn't exist."""
     data = self._yaml("type: Foobar")
     with pytest.raises(AttributeError,
                        match="Did not find type Foobar for test"):
         configdata._parse_yaml_type('test', data)
示例#12
0
 def test_simple(self):
     """Test type which is only a name."""
     data = self._yaml("type: Bool")
     typ = configdata._parse_yaml_type('test', data)
     assert isinstance(typ, configtypes.Bool)
     assert not typ.none_ok
示例#13
0
 def test_unknown_dict(self):
     """Test type parsing with a dict without keytype."""
     data = self._yaml("type: Dict")
     with pytest.raises(ValueError, match="Invalid node for test while "
                                          "reading 'keytype': 'Dict'"):
         configdata._parse_yaml_type('test', data)
示例#14
0
 def test_unknown_type(self):
     """Test type parsing with type which doesn't exist."""
     data = self._yaml("type: Foobar")
     with pytest.raises(AttributeError,
                        match="Did not find type Foobar for test"):
         configdata._parse_yaml_type('test', data)
示例#15
0
 def test_invalid_node(self):
     """Test type parsing with invalid node type."""
     data = self._yaml("type: 42")
     with pytest.raises(ValueError, match="Invalid node for test while "
                                          "reading type: 42"):
         configdata._parse_yaml_type('test', data)
示例#16
0
 def test_simple(self):
     """Test type which is only a name."""
     data = self._yaml("type: Bool")
     typ = configdata._parse_yaml_type('test', data)
     assert isinstance(typ, configtypes.Bool)
     assert not typ.none_ok