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)
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)
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)
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)
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
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
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
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
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
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
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)
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
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)
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)
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)
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