def test_save_method_saves_text_file(dietstorage):
    filename = 'tempfile.txt'
    content = 'This file is empty.'
    path = join(THIS_DIR, filename)
    tmppath = dietstorage.save_to_temp(path, content)
    new_path = dietstorage.save(path, open(tmppath, 'r'))
    try:
        assert exists(new_path)
        assert (open(new_path, 'r').read() == content)
        assert (not exists(tmppath))
    finally:
        os.remove(new_path)
def test_save_method_saves_text_file(dietstorage):
    filename = 'tempfile.txt'
    content = 'This file is empty.'
    path = join(THIS_DIR, filename)
    tmppath = dietstorage.save_to_temp(path, content)
    new_path = dietstorage.save(path, open(tmppath, 'r'))
    try:
        assert exists(new_path)
        assert (open(new_path, 'r').read() == content)
        assert (not exists(tmppath))
    finally:
        os.remove(new_path)