コード例 #1
0
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")
コード例 #2
0
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")
コード例 #3
0
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
コード例 #4
0
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