コード例 #1
0
    def test_close(self, m_read):
        tr = unix_events._UnixReadPipeTransport(
            self.loop, self.pipe, self.protocol)

        tr._close = unittest.mock.Mock()
        tr.close()
        tr._close.assert_called_with(None)
コード例 #2
0
    def test_close(self, m_read):
        tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe,
                                                self.protocol)

        tr._close = unittest.mock.Mock()
        tr.close()
        tr._close.assert_called_with(None)
コード例 #3
0
ファイル: unix_events_test.py プロジェクト: sah/tulip
    def test_close_already_closing(self, m_fcntl, m_read):
        tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe)

        tr._closing = True
        tr._close = unittest.mock.Mock()
        tr.close()
        self.assertFalse(tr._close.called)
コード例 #4
0
ファイル: unix_events_test.py プロジェクト: nerodong/tulip
    def test_pause(self, m_read):
        tr = unix_events._UnixReadPipeTransport(
            self.loop, self.pipe, self.protocol)

        m = unittest.mock.Mock()
        self.loop.add_reader(5, m)
        tr.pause()
        self.assertFalse(self.loop.readers)
コード例 #5
0
ファイル: unix_events_test.py プロジェクト: sah/tulip
    def test__close(self, m_fcntl, m_read):
        tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe)

        err = object()
        tr._close(err)
        self.assertTrue(tr._closing)
        self.loop.remove_reader.assert_called_with(5)
        self.loop.call_soon.assert_called_with(tr._call_connection_lost, err)
コード例 #6
0
    def test_close_already_closing(self, m_read):
        tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe,
                                                self.protocol)

        tr._closing = True
        tr._close = unittest.mock.Mock()
        tr.close()
        self.assertFalse(tr._close.called)
コード例 #7
0
    def test__call_connection_lost_with_err(self):
        tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe,
                                                self.protocol)

        err = OSError()
        tr._call_connection_lost(err)
        self.protocol.connection_lost.assert_called_with(err)
        self.pipe.close.assert_called_with()
コード例 #8
0
ファイル: unix_events_test.py プロジェクト: sah/tulip
    def test__call_connection_lost_with_err(self, m_fcntl):
        tr = unix_events._UnixReadPipeTransport(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()
コード例 #9
0
    def test__read_ready(self, m_read):
        tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe,
                                                self.protocol)
        m_read.return_value = b'data'
        tr._read_ready()

        m_read.assert_called_with(5, tr.max_size)
        self.protocol.data_received.assert_called_with(b'data')
コード例 #10
0
    def test__call_connection_lost(self):
        tr = unix_events._UnixReadPipeTransport(
            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
0
    def test_pause(self, m_read):
        tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe,
                                                self.protocol)

        m = unittest.mock.Mock()
        self.loop.add_reader(5, m)
        tr.pause()
        self.assertFalse(self.loop.readers)
コード例 #12
0
ファイル: unix_events_test.py プロジェクト: sah/tulip
    def test__read_ready(self, m_fcntl, m_read):
        tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe)
        tr.register_protocol(self.protocol)
        m_read.return_value = b'data'
        tr._read_ready()

        m_read.assert_called_with(5, tr.max_size)
        self.protocol.data_received.assert_called_with(b'data')
コード例 #13
0
    def test__close(self, m_read):
        tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe,
                                                self.protocol)

        err = object()
        tr._close(err)
        self.assertTrue(tr._closing)
        self.loop.remove_reader.assert_called_with(5)
        self.loop.call_soon.assert_called_with(tr._call_connection_lost, err)
コード例 #14
0
ファイル: unix_events_test.py プロジェクト: sah/tulip
    def test__read_ready_blocked(self, m_fcntl, m_read):
        tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe)
        tr.register_protocol(self.protocol)
        self.loop.reset_mock()
        m_read.side_effect = BlockingIOError
        tr._read_ready()

        m_read.assert_called_with(5, tr.max_size)
        self.assertFalse(self.protocol.data_received.called)
コード例 #15
0
    def test__read_ready_blocked(self, m_read):
        tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe,
                                                self.protocol)
        m_read.side_effect = BlockingIOError
        tr._read_ready()

        m_read.assert_called_with(5, tr.max_size)
        test_utils.run_briefly(self.loop)
        self.assertFalse(self.protocol.data_received.called)
コード例 #16
0
ファイル: unix_events_test.py プロジェクト: nerodong/tulip
    def test__read_ready_blocked(self, m_read):
        tr = unix_events._UnixReadPipeTransport(
            self.loop, self.pipe, self.protocol)
        m_read.side_effect = BlockingIOError
        tr._read_ready()

        m_read.assert_called_with(5, tr.max_size)
        test_utils.run_briefly(self.loop)
        self.assertFalse(self.protocol.data_received.called)
コード例 #17
0
    def test__close(self, m_read):
        tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe,
                                                self.protocol)

        err = object()
        tr._close(err)
        self.assertTrue(tr._closing)
        self.assertFalse(self.loop.readers)
        test_utils.run_briefly(self.loop)
        self.protocol.connection_lost.assert_called_with(err)
コード例 #18
0
ファイル: unix_events_test.py プロジェクト: sah/tulip
    def test__read_ready_error(self, m_fcntl, m_read, m_logexc):
        tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe)
        err = OSError()
        m_read.side_effect = err
        tr._close = unittest.mock.Mock()
        tr._read_ready()

        m_read.assert_called_with(5, tr.max_size)
        tr._close.assert_called_with(err)
        m_logexc.assert_called_with('Fatal error for %s', tr)
コード例 #19
0
ファイル: unix_events_test.py プロジェクト: nerodong/tulip
    def test__close(self, m_read):
        tr = unix_events._UnixReadPipeTransport(
            self.loop, self.pipe, self.protocol)

        err = object()
        tr._close(err)
        self.assertTrue(tr._closing)
        self.assertFalse(self.loop.readers)
        test_utils.run_briefly(self.loop)
        self.protocol.connection_lost.assert_called_with(err)
コード例 #20
0
ファイル: unix_events_test.py プロジェクト: nerodong/tulip
    def test__read_ready_eof(self, m_read):
        tr = unix_events._UnixReadPipeTransport(
            self.loop, self.pipe, self.protocol)
        m_read.return_value = b''
        tr._read_ready()

        m_read.assert_called_with(5, tr.max_size)
        self.assertFalse(self.loop.readers)
        test_utils.run_briefly(self.loop)
        self.protocol.eof_received.assert_called_with()
        self.protocol.connection_lost.assert_called_with(None)
コード例 #21
0
    def test__read_ready_eof(self, m_read):
        tr = unix_events._UnixReadPipeTransport(
            self.loop, self.pipe, self.protocol)
        m_read.return_value = b''
        tr._read_ready()

        m_read.assert_called_with(5, tr.max_size)
        self.loop.remove_reader.assert_called_with(5)
        self.loop.call_soon.assert_has_calls([
            unittest.mock.call(self.protocol.eof_received),
            unittest.mock.call(tr._call_connection_lost, None)])
コード例 #22
0
    def test__read_ready_error(self, m_read, m_logexc):
        tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe,
                                                self.protocol)
        err = OSError()
        m_read.side_effect = err
        tr._close = unittest.mock.Mock()
        tr._read_ready()

        m_read.assert_called_with(5, tr.max_size)
        tr._close.assert_called_with(err)
        m_logexc.assert_called_with('Fatal error for %s', tr)
コード例 #23
0
    def test__read_ready_eof(self, m_read):
        tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe,
                                                self.protocol)
        m_read.return_value = b''
        tr._read_ready()

        m_read.assert_called_with(5, tr.max_size)
        self.assertFalse(self.loop.readers)
        test_utils.run_briefly(self.loop)
        self.protocol.eof_received.assert_called_with()
        self.protocol.connection_lost.assert_called_with(None)
コード例 #24
0
    def test__read_ready_eof(self, m_read):
        tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe,
                                                self.protocol)
        m_read.return_value = b''
        tr._read_ready()

        m_read.assert_called_with(5, tr.max_size)
        self.loop.remove_reader.assert_called_with(5)
        self.loop.call_soon.assert_has_calls([
            unittest.mock.call(self.protocol.eof_received),
            unittest.mock.call(tr._call_connection_lost, None)
        ])
コード例 #25
0
ファイル: unix_events_test.py プロジェクト: nerodong/tulip
    def test__call_connection_lost_with_err(self):
        tr = unix_events._UnixReadPipeTransport(
            self.loop, self.pipe, self.protocol)

        err = OSError()
        tr._call_connection_lost(err)
        self.protocol.connection_lost.assert_called_with(err)
        self.pipe.close.assert_called_with()

        self.assertIsNone(tr._protocol)
        self.assertEqual(2, sys.getrefcount(self.protocol),
                         pprint.pformat(gc.get_referrers(self.protocol)))
        self.assertIsNone(tr._loop)
        self.assertEqual(2, sys.getrefcount(self.loop),
                         pprint.pformat(gc.get_referrers(self.loop)))
コード例 #26
0
    def test__call_connection_lost_with_err(self):
        tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe,
                                                self.protocol)

        err = OSError()
        tr._call_connection_lost(err)
        self.protocol.connection_lost.assert_called_with(err)
        self.pipe.close.assert_called_with()

        self.assertIsNone(tr._protocol)
        self.assertEqual(2, sys.getrefcount(self.protocol),
                         pprint.pformat(gc.get_referrers(self.protocol)))
        self.assertIsNone(tr._loop)
        self.assertEqual(2, sys.getrefcount(self.loop),
                         pprint.pformat(gc.get_referrers(self.loop)))
コード例 #27
0
ファイル: unix_events_test.py プロジェクト: nerodong/tulip
    def test_resume(self, m_read):
        tr = unix_events._UnixReadPipeTransport(
            self.loop, self.pipe, self.protocol)

        tr.resume()
        self.loop.assert_reader(5, tr._read_ready)
コード例 #28
0
ファイル: unix_events_test.py プロジェクト: sah/tulip
 def test_ctor_with_waiter(self, m_fcntl):
     fut = futures.Future()
     unix_events._UnixReadPipeTransport(
         self.loop, self.pipe, fut)
     self.loop.call_soon.assert_called_with(fut.set_result, None)
     fut.cancel()
コード例 #29
0
 def test_ctor(self):
     tr = unix_events._UnixReadPipeTransport(
         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)
コード例 #30
0
    def test_resume(self, m_read):
        tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe,
                                                self.protocol)

        tr.resume()
        self.loop.assert_reader(5, tr._read_ready)
コード例 #31
0
 def test_ctor_with_waiter(self):
     fut = futures.Future(loop=self.loop)
     unix_events._UnixReadPipeTransport(self.loop, self.pipe, self.protocol,
                                        fut)
     self.loop.call_soon.assert_called_with(fut.set_result, None)
     fut.cancel()
コード例 #32
0
 def test_ctor(self):
     tr = unix_events._UnixReadPipeTransport(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)
コード例 #33
0
ファイル: unix_events_test.py プロジェクト: sah/tulip
 def test_ctor(self, m_fcntl):
     tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe)
     self.assertEqual(self.loop.call_soon.call_count, 0)
コード例 #34
0
    def test_pause(self, m_read):
        tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe,
                                                self.protocol)

        tr.pause()
        self.loop.remove_reader.assert_called_with(5)
コード例 #35
0
 def test_ctor_with_waiter(self):
     fut = futures.Future(loop=self.loop)
     unix_events._UnixReadPipeTransport(self.loop, self.pipe, self.protocol,
                                        fut)
     test_utils.run_briefly(self.loop)
     self.assertIsNone(fut.result())
コード例 #36
0
 def test_ctor(self):
     tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe,
                                             self.protocol)
     self.loop.assert_reader(5, tr._read_ready)
     test_utils.run_briefly(self.loop)
     self.protocol.connection_made.assert_called_with(tr)
コード例 #37
0
ファイル: unix_events_test.py プロジェクト: nerodong/tulip
 def test_ctor_with_waiter(self):
     fut = futures.Future(loop=self.loop)
     unix_events._UnixReadPipeTransport(
         self.loop, self.pipe, self.protocol, fut)
     test_utils.run_briefly(self.loop)
     self.assertIsNone(fut.result())
コード例 #38
0
ファイル: unix_events_test.py プロジェクト: sah/tulip
    def test_pause(self, m_fcntl, m_read):
        tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe)

        tr.pause()
        self.loop.remove_reader.assert_called_with(5)
コード例 #39
0
ファイル: unix_events_test.py プロジェクト: sah/tulip
    def test_resume(self, m_fcntl, m_read):
        tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe)

        tr.resume()
        self.loop.add_reader.assert_called_with(5, tr._read_ready)
コード例 #40
0
ファイル: unix_events_test.py プロジェクト: sah/tulip
 def test_register_protocol(self, m_fcntl):
     tr = unix_events._UnixReadPipeTransport(self.loop, self.pipe)
     tr.register_protocol(self.protocol)
     self.loop.add_reader.assert_called_with(5, tr._read_ready)
コード例 #41
0
ファイル: unix_events_test.py プロジェクト: nerodong/tulip
 def test_ctor(self):
     tr = unix_events._UnixReadPipeTransport(
         self.loop, self.pipe, self.protocol)
     self.loop.assert_reader(5, tr._read_ready)
     test_utils.run_briefly(self.loop)
     self.protocol.connection_made.assert_called_with(tr)