示例#1
0
文件: servers.py 项目: rusek/across
def _set_debug_level_and_connect():
    set_debug_level(10)
    handler = ProcessConnectionHandler()
    with ServerWorker(run_tcp, localhost, 0, handler=handler) as worker:
        with Connection.from_tcp(*worker.address) as conn:
            if conn.call(get_debug_level) != 10:
                raise AssertionError
示例#2
0
文件: servers.py 项目: rusek/across
 def __run_stopping_test(self, handler):
     with ServerWorker(run_tcp, localhost, 0, handler=handler) as worker:
         conn = Connection.from_tcp(*worker.address)
         self.assertEqual(conn.call(add, 1, 2), 3)
     self.assertRaises(DisconnectError, conn.call, add, 1, 2)
     try:
         conn.close()
     except OSError:  # Connection reset by peer on Windows
         pass
示例#3
0
文件: servers.py 项目: rusek/across
 def test_bios_handler(self):
     handler = BIOSConnectionHandler()
     # Child process may be interrupted during interpreter shutdown, causing various errors to be
     # printed on stderr. Let's suppress them.
     with InheritableStderrCollector():
         with ServerWorker(run_tcp, localhost, 0,
                           handler=handler) as worker:
             with Connection.from_tcp(*worker.address) as conn:
                 self.assertEqual(conn.call(add, 1, 2), 3)
                 self.assertNotEqual(conn.call(os.getpid), os.getpid())
示例#4
0
文件: servers.py 项目: rusek/across
    def test_multiple_connections(self):
        with ServerWorker(run_tcp, localhost, 0) as worker:
            num_conns = 5

            conns = [
                Connection.from_tcp(*worker.address) for _ in range(num_conns)
            ]

            for i, conn in enumerate(conns):
                self.assertEqual(conn.call(add, i, 1), i + 1)

            for conn in conns:
                conn.close()
示例#5
0
文件: servers.py 项目: rusek/across
 def test_tcp_dual_stack(self):
     with ServerWorker(run_tcp, anyaddr_ipv6, 0) as worker:
         with Connection.from_tcp(localhost, worker.address[1]) as conn:
             self.assertEqual(conn.call(add, 1, 2), 3)
示例#6
0
文件: servers.py 项目: rusek/across
 def test_tcp_ipv6(self):
     with ServerWorker(run_tcp, localhost_ipv6, 0) as worker:
         with Connection.from_tcp(*worker.address[:2]) as conn:
             self.assertEqual(conn.call(add, 1, 2), 3)