コード例 #1
0
def test_writable_stream3():
    buff = io.StringIO()
    with pytest.raises(Exception):
        with writers.writable(buff, 'wt') as f:
            f.write('x')
            raise Exception()
    assert not f.closed
コード例 #2
0
ファイル: test_writers.py プロジェクト: heuer/segno
def test_writable_stream3():
    buff = io.StringIO()
    with pytest.raises(Exception):
        with writers.writable(buff, 'wt') as f:
            f.write('x')
            raise Exception()
    assert not f.closed
コード例 #3
0
def test_writable_not_stream3():
    fn = tempfile.NamedTemporaryFile()
    name = fn.name
    fn.close()
    with pytest.raises(Exception):
        with writers.writable(name, 'wb') as f:
            assert name == f.name
            f.write(b'Segno')
            raise Exception()
    assert f.closed
コード例 #4
0
def test_writable_not_stream2():
    fn = tempfile.NamedTemporaryFile()
    name = fn.name
    fn.close()
    try:
        with writers.writable(name, 'wt') as f:
            assert name == f.name
            f.write('Segno')
    finally:
        os.remove(name)
コード例 #5
0
ファイル: test_writers.py プロジェクト: heuer/segno
def test_writable_not_stream3():
    fn = tempfile.NamedTemporaryFile()
    name = fn.name
    fn.close()
    with pytest.raises(Exception):
        with writers.writable(name, 'wb') as f:
            assert name == f.name
            f.write(b'Segno')
            raise Exception()
    assert f.closed
コード例 #6
0
ファイル: test_writers.py プロジェクト: heuer/segno
def test_writable_not_stream2():
    fn = tempfile.NamedTemporaryFile()
    name = fn.name
    fn.close()
    try:
        with writers.writable(name, 'wt') as f:
            assert name == f.name
            f.write('Segno')
    finally:
        os.remove(name)
コード例 #7
0
def test_writable_stream2():
    buff = io.StringIO()
    with writers.writable(buff, 'wt') as f:
        f.write('x')
    assert not buff.closed
コード例 #8
0
def test_writable_stream():
    buff = io.BytesIO()
    with writers.writable(buff, 'wb') as f:
        f.write(b'x')
    assert not buff.closed
コード例 #9
0
ファイル: test_writers.py プロジェクト: heuer/segno
def test_writable_stream2():
    buff = io.StringIO()
    with writers.writable(buff, 'wt') as f:
        f.write('x')
    assert not buff.closed
コード例 #10
0
ファイル: test_writers.py プロジェクト: heuer/segno
def test_writable_stream():
    buff = io.BytesIO()
    with writers.writable(buff, 'wb') as f:
        f.write(b'x')
    assert not buff.closed