
file.write is not returning number of bytes writen and partial writes were not handled properly. New implementation is using os module calls which support partial writes. It also implements missing calls from file object (like seek, tell, truncate, ...). The later is not very usefull, because regular files never return EAGAIN. New GreenPipe can be constructed from int, string or file object.
26 lines
521 B
Python
26 lines
521 B
Python
from __future__ import with_statement
|
|
|
|
import os
|
|
|
|
from tests import LimitedTestCase
|
|
|
|
from eventlet import greenio
|
|
|
|
class TestGreenPipeWithStatement(LimitedTestCase):
|
|
def test_pipe_context(self):
|
|
# ensure using a pipe as a context actually closes it.
|
|
r, w = os.pipe()
|
|
|
|
r = greenio.GreenPipe(r)
|
|
w = greenio.GreenPipe(w, 'w')
|
|
|
|
with r:
|
|
pass
|
|
|
|
assert r.closed and not w.closed
|
|
|
|
with w as f:
|
|
assert f == w
|
|
|
|
assert r.closed and w.closed
|