def test_newline_at_EOF(): """http://stackoverflow.com/a/729795""" f = NamedTemporaryFile(delete=False) prop = Properties(OrderedDict([("a", "b"), ("c", "d"), ("e", "f")])) prop.save(f.name) with open(f.name) as f: lastline = f.readlines()[-1] os.remove(f.name) assert lastline.endswith("\n")
def test_newline_at_EOF(): """http://stackoverflow.com/a/729795""" f = NamedTemporaryFile(delete=False) prop = Properties(OrderedDict([ ("a", "b"), ("c", "d"), ("e", "f") ])) prop.save(f.name) with open(f.name) as f: lastline = f.readlines()[-1] os.remove(f.name) assert lastline.endswith("\n")
def test_save(): properties = """ foo : bar bar : baz """ p = Properties() p2 = Properties() p.load(StringIO(properties)) with NamedTemporaryFile(delete=False) as f: p.save(f.name) with open(f.name) as f: p2.load(f) os.remove(f.name) assert p == p2