def test_file_not_copied(tmpdir): tmpdir.join('old_file').write('contents here') f = AtomicFile(tmpdir.join('old_file').strpath, copy_existing=False) assert f.read() == '' f.close()
def test_file_creation(tmpdir): fn = str(tmpdir.join('test')) f = AtomicFile(fn) f.write('this is a test') f.close() with open(fn) as f: assert f.read() == 'this is a test'
def test_file_copied(tmpdir): tmpdir.join('old_file').write('contents here') f = AtomicFile(tmpdir.join('old_file').strpath) assert f.read() == 'contents here' f.close()