コード例 #1
0
    def test_get_extra_info(self):
        transport = transports.Transport({'extra': 'info'})
        self.assertEqual('info', transport.get_extra_info('extra'))
        self.assertIsNone(transport.get_extra_info('unknown'))

        default = object()
        self.assertIs(default, transport.get_extra_info('unknown', default))
コード例 #2
0
    def test_writelines(self):
        transport = transports.Transport()
        transport.write = unittest.mock.Mock()

        transport.writelines(
            [b'line1', bytearray(b'line2'),
             memoryview(b'line3')])
        self.assertEqual(1, transport.write.call_count)
        transport.write.assert_called_with(b'line1line2line3')
コード例 #3
0
ファイル: test_transports.py プロジェクト: 5l1v3r1/cpython-1
    def test_not_implemented(self):
        transport = transports.Transport()

        self.assertRaises(NotImplementedError, transport.write, 'data')
        self.assertRaises(NotImplementedError, transport.write_eof)
        self.assertRaises(NotImplementedError, transport.can_write_eof)
        self.assertRaises(NotImplementedError, transport.pause_reading)
        self.assertRaises(NotImplementedError, transport.resume_reading)
        self.assertRaises(NotImplementedError, transport.close)
        self.assertRaises(NotImplementedError, transport.abort)
コード例 #4
0
 def test_ctor_extra_is_none(self):
     transport = transports.Transport()
     self.assertEqual(transport._extra, {})
コード例 #5
0
ファイル: test_transports.py プロジェクト: 5l1v3r1/cpython-1
    def test_writelines(self):
        transport = transports.Transport()
        transport.write = unittest.mock.Mock()

        transport.writelines(['line1', 'line2', 'line3'])
        self.assertEqual(3, transport.write.call_count)