Exemplo n.º 1
0
def test_sponge_that_on_exception_file_isnt_modified():
    with _directory_sandbox():
        open('foo', 'w').write('bar')
        try:
            with _sponge('foo') as f:
                f.write('hello')
                raise RuntimeError()
        except RuntimeError:
            pass
        assert open('foo').read() == 'bar'
Exemplo n.º 2
0
def test_sponge_that_on_exception_file_isnt_modified():
    with _directory_sandbox():
        open('foo', 'w').write('bar')
        try:
            with _sponge('foo') as f:
                f.write('hello')
                raise RuntimeError()
        except RuntimeError:
            pass
        assert open('foo').read() == 'bar'
Exemplo n.º 3
0
def test_sponge_that_new_data_end_up_in_file():
    with _directory_sandbox():
        with _sponge('hello') as f:
            f.write('hello')
        assert open('hello').read() == 'hello'
Exemplo n.º 4
0
def test_sponge_that_new_data_end_up_in_file():
    with _directory_sandbox():
        with _sponge('hello') as f:
            f.write('hello')
        assert open('hello').read() == 'hello'