async: remove AsyncWriter

we are not expecting real-time problems on the sender's side.
This commit is contained in:
Roman Zeyde
2015-02-04 18:07:25 +02:00
parent 1b64e2874a
commit 6a35820155
4 changed files with 2 additions and 90 deletions

View File

@@ -22,49 +22,9 @@ def test_async_reader():
r.close()
def test_async_write():
result = []
def _write(buf):
time.sleep(len(buf) * 0.1)
result.append(buf)
s = mock.Mock()
s.write = _write
w = async.AsyncWriter(s)
w.write('foo')
w.write(' ')
w.write('bar')
w.close()
assert w.stream is None
w.close()
assert result == ['foo', ' ', 'bar']
def test_async_reader_error():
s = mock.Mock()
s.read.side_effect = IOError()
r = async.AsyncReader(s, 1)
with pytest.raises(IOError):
r.read(3)
def test_async_writer_error():
s = mock.Mock()
s.write.side_effect = IOError()
w = async.AsyncWriter(s)
w.write('123')
w.thread.join()
with pytest.raises(IOError):
w.write('456')
assert s.write.mock_calls == [mock.call('123')]
def test_underflow():
s = mock.Mock()
w = async.AsyncWriter(s)
w.write('blah')
w.thread.join()
assert s.write.mock_calls == [mock.call('blah')]
with pytest.raises(IOError):
w.write('xyzw')