Ejemplo n.º 1
0
    def test_start(self, select):
        select.select.side_effect = [KeyboardInterrupt, SystemExit]
        # TODO: v6 not supported on Travis
        # s1 = Server(mock.MagicMock(), '::1', '1234')
        # s1.start()
        # self.assertEqual(s1.socket.family, socket.AF_INET6)

        s2 = Server(mock.MagicMock(), '127.0.0.1', '2345')
        s2.start()
        self.assertEqual(s2.socket.family, socket.AF_INET6)

        s2 = Server(mock.MagicMock(), 'foo', '80')
        s2.start()
        self.assertFalse(s2.running)
Ejemplo n.º 2
0
    def test_start(self, select):
        select.select.side_effect = [KeyboardInterrupt, SystemExit]
        ipv6_test = False
        if _ipv6_available('::1', '1234'):
            ipv6_test = True
            s1 = Server(mock.MagicMock(), '::1', '1234')
            s1.start()
            self.assertEqual(s1.socket.family, socket.AF_INET6)

            original_so_rcvbuf = s1.socket.getsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF)

        s2 = Server(mock.MagicMock(), '127.0.0.1', '2345', so_rcvbuf=1023)
        s2.start()
        self.assertEqual(s2.socket.family, socket.AF_INET6)

        if ipv6_test:
            self.assertNotEquals(original_so_rcvbuf, s2.socket.getsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF))

        s2 = Server(mock.MagicMock(), 'foo', '80')
        s2.start()
        self.assertFalse(s2.running)
Ejemplo n.º 3
0
    def test_start(self, select):
        select.select.side_effect = [KeyboardInterrupt, SystemExit]
        ipv6_test = False
        if _ipv6_available('::1', '1234'):
            ipv6_test = True
            s1 = Server(mock.MagicMock(), '::1', '1234')
            s1.start()
            self.assertEqual(s1.socket.family, socket.AF_INET6)

            original_so_rcvbuf = s1.socket.getsockopt(socket.SOL_SOCKET,
                                                      socket.SO_RCVBUF)

        s2 = Server(mock.MagicMock(), '127.0.0.1', '2345', so_rcvbuf=1023)
        s2.start()
        self.assertEqual(s2.socket.family, socket.AF_INET6)

        if ipv6_test:
            self.assertNotEquals(
                original_so_rcvbuf,
                s2.socket.getsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF))

        s2 = Server(mock.MagicMock(), 'foo', '80')
        s2.start()
        self.assertFalse(s2.running)