asyncio: Improve default writelines().

This commit is contained in:
Guido van Rossum 2013-12-02 18:36:30 -08:00
parent afbf827875
commit f10345e102
2 changed files with 20 additions and 6 deletions

View file

@ -24,12 +24,18 @@ class TransportTests(unittest.TestCase):
transport = transports.Transport()
transport.write = unittest.mock.Mock()
transport.writelines(['line1', 'line2', 'line3'])
self.assertEqual(3, transport.write.call_count)
transport.writelines([b'line1',
bytearray(b'line2'),
memoryview(b'line3')])
self.assertEqual(1, transport.write.call_count)
transport.write.assert_called_with(b'line1line2line3')
def test_not_implemented(self):
transport = transports.Transport()
self.assertRaises(NotImplementedError,
transport.set_write_buffer_limits)
self.assertRaises(NotImplementedError, transport.get_write_buffer_size)
self.assertRaises(NotImplementedError, transport.write, 'data')
self.assertRaises(NotImplementedError, transport.write_eof)
self.assertRaises(NotImplementedError, transport.can_write_eof)