Пример #1
0
def test_dict_builder_hsdattr(hsdstr, hsddict):
    """Test transformation from hsd to dictionary with HSD attributes."""
    dictbuilder = hsd.HsdDictBuilder(include_hsd_attribs=True)
    parser = hsd.HsdParser(eventhandler=dictbuilder)
    fobj = io.StringIO(hsdstr)
    parser.parse(fobj)
    assert dictbuilder.hsddict == hsddict
Пример #2
0
def test_dictbuilder_flat():
    dictbuilder = hsd.HsdDictBuilder(flatten_data=True)
    parser = hsd.HsdParser(eventhandler=dictbuilder)
    with open(op.join(op.dirname(__file__), "test.hsd"), "r") as fobj:
        parser.feed(fobj)
    pyrep = dictbuilder.hsddict
    print("** Python structure with data flattening:\n")
    print(pyrep)
    print("\n** Turning back to HSD:\n")
    print(hsd.dumps(pyrep))