示例#1
0
 def setUp(self):
     self.loop = loop.make()
     self.connect_count = 0
     self.error_count = 0
     self.last_error_type = None
     self.last_error = None
     self.timeout_hit = False
     self.conn = None
     def check_connect(conn):
         self.conn = conn
         self.assertTrue(conn.tcp_connected)
         self.connect_count += 1
         conn.write(b"test")
         conn.close()
         self.loop.schedule(1, self.loop.stop)
     def check_error(err_type, err_id, err_str):
         self.error_count += 1
         self.last_error_type = err_type
         self.last_error = err_id
         self.loop.schedule(1, self.loop.stop)
     def timeout():
         self.loop.stop()
         self.timeout_hit = True
     self.timeout = timeout
     self.client = TcpClient(self.loop)
     self.client.on('connect', check_connect)
     self.client.on('connect_error', check_error)
示例#2
0
 def setUp(self):
     self.loop = loop.make()
     self.ep1 = UdpEndpoint(self.loop)
     self.ep1.bind(test_host, test_port)
     self.ep1.on('datagram', self.input)
     self.ep1.pause(False)
     self.ep2 = UdpEndpoint()
     self.loop.schedule(5, self.timeout)
     self.timeout_hit = False
     self.datagrams = []
示例#3
0
文件: test_dns.py 项目: mnot/thor
 def setUp(self):
     self.loop = loop.make()
     self.loop.schedule(5, self.timeout)
     self.timeout_hit = False