def test_simple_back_to_ordered(simple_namelist): nl = Namelist(simple_namelist) assert len(nl) > 0 back = nl.namelist() assert len(back) == len(simple_namelist) for back_key, key in zip(back, simple_namelist): assert back_key == key assert back[key] == simple_namelist[key]
def test_recursive_back_to_ordered(recursive_namelist): from collections import OrderedDict nl = Namelist(recursive_namelist) assert len(nl) > 0 back = nl.namelist() assert len(back) == len(recursive_namelist) for back_key, key in zip(back, recursive_namelist): assert back_key == key assert isinstance(back[key], OrderedDict)
def test_none_arguments_do_not_appear_in_dict(simple_namelist): nl = Namelist(simple_namelist) nl.ibrav = None assert 'ibrav' not in nl.namelist()