本文整理汇总了Python中tulip.unix_events._UnixWritePipeTransport函数的典型用法代码示例。如果您正苦于以下问题:Python _UnixWritePipeTransport函数的具体用法?Python _UnixWritePipeTransport怎么用?Python _UnixWritePipeTransport使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_UnixWritePipeTransport函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_write_eof_pending
def test_write_eof_pending(self, m_fcntl):
tr = unix_events._UnixWritePipeTransport(self.loop, self.pipe)
tr.register_protocol(self.protocol)
tr._buffer = [b'data']
tr.write_eof()
self.assertTrue(tr._closing)
self.assertFalse(self.protocol.connection_lost.called)
示例2: test_ctor_with_waiter
def test_ctor_with_waiter(self):
fut = futures.Future(loop=self.loop)
tr = unix_events._UnixWritePipeTransport(
self.loop, self.pipe, self.protocol, fut)
self.loop.assert_reader(5, tr._read_ready)
test_utils.run_briefly(self.loop)
self.assertEqual(None, fut.result())
示例3: test_pause_resume_writing
def test_pause_resume_writing(self):
tr = unix_events._UnixWritePipeTransport(
self.loop, self.pipe, self.protocol)
tr.pause_writing()
self.assertFalse(tr._writing)
tr.resume_writing()
self.assertTrue(tr._writing)
示例4: test_write_eof
def test_write_eof(self, m_fcntl):
tr = unix_events._UnixWritePipeTransport(self.loop, self.pipe)
tr.write_eof()
self.assertTrue(tr._closing)
self.loop.call_soon.assert_called_with(
tr._call_connection_lost, None)
示例5: test_close
def test_close(self):
tr = unix_events._UnixWritePipeTransport(
self.loop, self.pipe, self.protocol)
tr.write_eof = unittest.mock.Mock()
tr.close()
tr.write_eof.assert_called_with()
示例6: test_discard_output_without_pending_writes
def test_discard_output_without_pending_writes(self):
tr = unix_events._UnixWritePipeTransport(
self.loop, self.pipe, self.protocol)
tr.discard_output()
self.assertTrue(tr._writing)
self.assertFalse(self.loop.remove_writer.called)
self.assertEqual([], tr._buffer)
示例7: test_close_closing
def test_close_closing(self, m_fcntl):
tr = unix_events._UnixWritePipeTransport(self.loop, self.pipe)
tr.write_eof = unittest.mock.Mock()
tr._closing = True
tr.close()
self.assertFalse(tr.write_eof.called)
示例8: test_ctor
def test_ctor(self):
tr = unix_events._UnixWritePipeTransport(
self.loop, self.pipe, self.protocol)
self.loop.add_reader.assert_called_with(5, tr._read_ready)
self.loop.call_soon.assert_called_with(
self.protocol.connection_made, tr)
self.assertTrue(tr._enable_read_hack)
示例9: test_write_no_data
def test_write_no_data(self, m_fcntl, m_write):
tr = unix_events._UnixWritePipeTransport(self.loop, self.pipe)
tr.write(b'')
self.assertFalse(m_write.called)
self.assertFalse(self.loop.add_writer.called)
self.assertEqual([], tr._buffer)
示例10: test__call_connection_lost
def test__call_connection_lost(self):
tr = unix_events._UnixWritePipeTransport(
self.loop, self.pipe, self.protocol)
err = None
tr._call_connection_lost(err)
self.protocol.connection_lost.assert_called_with(err)
self.pipe.close.assert_called_with()
示例11: test_ctor_with_waiter
def test_ctor_with_waiter(self):
fut = futures.Future(loop=self.loop)
tr = unix_events._UnixWritePipeTransport(
self.loop, self.pipe, self.protocol, fut)
self.loop.call_soon.assert_called_with(fut.set_result, None)
self.loop.add_reader.assert_called_with(5, tr._read_ready)
self.assertTrue(tr._enable_read_hack)
fut.cancel()
示例12: test__call_connection_lost_with_err
def test__call_connection_lost_with_err(self, m_fcntl):
tr = unix_events._UnixWritePipeTransport(self.loop, self.pipe)
tr.register_protocol(self.protocol)
err = OSError()
tr._call_connection_lost(err)
self.protocol.connection_lost.assert_called_with(err)
self.pipe.close.assert_called_with()
示例13: test_discard_output
def test_discard_output(self):
tr = unix_events._UnixWritePipeTransport(
self.loop, self.pipe, self.protocol)
tr._buffer = [b'da', b'ta']
tr.discard_output()
self.assertTrue(tr._writing)
self.loop.remove_writer.assert_called_with(5)
self.assertEqual([], tr._buffer)
示例14: test_ctor_with_regular_file
def test_ctor_with_regular_file(self):
with tempfile.TemporaryFile() as f:
tr = unix_events._UnixWritePipeTransport(self.loop, f,
self.protocol)
self.assertFalse(self.loop.add_reader.called)
self.loop.call_soon.assert_called_with(
self.protocol.connection_made, tr)
self.assertFalse(tr._enable_read_hack)
示例15: test_write_again
def test_write_again(self, m_fcntl, m_write):
tr = unix_events._UnixWritePipeTransport(self.loop, self.pipe)
m_write.side_effect = BlockingIOError()
tr.write(b'data')
m_write.assert_called_with(5, b'data')
self.loop.add_writer.assert_called_with(5, tr._write_ready)
self.assertEqual([b'data'], tr._buffer)