def parse_doc(self, content): # smb.conf is special from other ini files in the property that # whatever is before the first section (before the first section) # belongs to the [global] section. Therefore, the [global] section is # appended right at the beginning so that everything that would be # parsed as outside section belongs to [global]. # Python 2.7 RawConfigParser automatically merges multiple instances # of the same section. (And if that ever changes, test_samba.py will # catch it.) lstripped = ["[global]"] + [line.lstrip() for line in content] return iniparser.parse_doc("\n".join(lstripped), self, return_defaults=True, return_booleans=False)
def test_no_value(): res = parse_doc(DATA, None) assert res["novalue"]["the_force"][0].value is None
def test_multiple_values(): res = parse_doc(DATA, None) assert len(res["settings"]["color"]) == 2 assert res["settings"]["accuracy"][0].value == "0" assert res["settings"]["banks"][0].value == "0 1 2"
def test_defaults(): res = parse_doc(DATA, None) assert res["facts"]["trooper_guns"][0].value == "miss"
def test_hanging_indent(): res = parse_doc(DATA, None) assert res["facts"]["vader"][0].value == "definitely Luke's father"
def test_iniparser(): res = parse_doc(DATA, None) assert len(res) == 5
def parse_doc(self, content): return iniparser.parse_doc("\n".join(content), self)