mirror of
https://github.com/romanz/amodem.git
synced 2026-03-24 11:22:00 +08:00
async: remove AsyncWriter
we are not expecting real-time problems on the sender's side.
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user