def test_commit_discard(tmpdir): tmpdir = str(tmpdir) fs = LocalFileSystem() with fs.transaction: with fs.open(tmpdir + "/afile", "wb") as f: assert not fs.exists(tmpdir + "/afile") f.write(b"data") assert not fs.exists(tmpdir + "/afile") assert fs.cat(tmpdir + "/afile") == b"data" try: with fs.transaction: with fs.open(tmpdir + "/bfile", "wb") as f: f.write(b"data") raise KeyboardInterrupt except KeyboardInterrupt: assert not fs.exists(tmpdir + "/bfile")
def test_commit_discard(tmpdir): tmpdir = str(tmpdir) fs = LocalFileSystem() with fs.transaction: with fs.open(tmpdir + '/afile', 'wb') as f: assert not fs.exists(tmpdir + '/afile') f.write(b'data') assert not fs.exists(tmpdir + '/afile') assert fs.cat(tmpdir + '/afile') == b'data' try: with fs.transaction: with fs.open(tmpdir + '/bfile', 'wb') as f: f.write(b'data') raise KeyboardInterrupt except KeyboardInterrupt: assert not fs.exists(tmpdir + '/bfile')