def test_set_bad_type(t): s = zini.Section() s['a'] = t assert isinstance(s['a'], zini.GenericParser)
def test_set_bad_key(): s = zini.Section() with pytest.raises(TypeError): s[13] = int
def test_create_empty(): s = zini.Section() assert not s
def test_set_list_item_parser(value, item_parser_class): s = zini.Section() s['a'] = value assert s assert isinstance(s['a'], zini.ListParser) assert isinstance(s['a'].item_parser, item_parser_class)
def test_set_default(value, parser_class): s = zini.Section() s['a'] = value assert s assert isinstance(s['a'], parser_class)
def test_set_parser(): s = zini.Section() parser = zini.BooleanParser() s['a'] = parser assert s['a'] is parser
def test_set_type(t, parser_class): s = zini.Section() s['a'] = t assert s assert isinstance(s['a'], parser_class)
def test_del(): s = zini.Section() s['a'] = int assert s del s['a'] assert not s
def test_create(): s = zini.Section({'a': int}) assert s assert 'a' in s