Пример #1
0
class TestSocketErrors:
    def _callback(self, *args, **kwargs):
        self.callback_fired = True

    def setup(self):
        self.callback_fired = False
        self.r = ThreadedReactorSocketError()
        self.r.listen_udp(tc.CLIENT_ADDR[1], lambda x, y: None)

    def test_sendto(self):
        logger.critical('TESTING: IGNORE CRITICAL MESSAGE')
        self.r.sendto('z', tc.NO_ADDR)

    def test_recvfrom(self):
        self.r.start()
        r2 = ThreadedReactor()
        r2.listen_udp(tc.SERVER_ADDR[1], lambda x, y: None)
        logger.critical('TESTING: IGNORE CRITICAL MESSAGE')
        r2.sendto('z', tc.CLIENT_ADDR)
        # self.r will call recvfrom (which raises socket.error)
        time.sleep(tc.TASK_INTERVAL)
        ok_(not self.callback_fired)
        self.r.stop()

    def test_sendto_too_large_data_string(self):
        logger.critical('TESTING: IGNORE CRITICAL MESSAGE')
        self.r.sendto('z' * 12345, tc.NO_ADDR)
Пример #2
0
class TestSocketErrors:

    def _callback(self, *args, **kwargs):
        self.callback_fired = True
    
    def setup(self):
        self.callback_fired = False
        self.r = ThreadedReactorSocketError()
        self.r.listen_udp(tc.CLIENT_ADDR[1], lambda x,y:None)

    def test_sendto(self):
        logger.critical('TESTING: IGNORE CRITICAL MESSAGE')
        self.r.sendto('z', tc.NO_ADDR)

    def test_recvfrom(self):
        self.r.start()
        r2 = ThreadedReactor()
        r2.listen_udp(tc.SERVER_ADDR[1], lambda x,y:None)
        logger.critical('TESTING: IGNORE CRITICAL MESSAGE')
        r2.sendto('z', tc.CLIENT_ADDR)
        # self.r will call recvfrom (which raises socket.error)
        time.sleep(tc.TASK_INTERVAL)
        ok_(not self.callback_fired)
        self.r.stop()

    def test_sendto_too_large_data_string(self):
        logger.critical('TESTING: IGNORE CRITICAL MESSAGE')
        self.r.sendto('z'*12345, tc.NO_ADDR)
Пример #3
0
 def setup(self):
     self.callback_fired = False
     self.r = ThreadedReactorSocketError()
     self.r.listen_udp(tc.CLIENT_ADDR[1], lambda x, y: None)
Пример #4
0
 def setup(self):
     self.callback_fired = False
     self.r = ThreadedReactorSocketError()
     self.r.listen_udp(tc.CLIENT_ADDR[1], lambda x,y:None)