Exemplo n.º 1
0
    def _test_sendall(self,
                      data,
                      match_data=None,
                      client_method='sendall',
                      **client_args):

        read_data = []
        server_exc_info = []

        def accept_and_read():
            try:
                conn, _ = self.listener.accept()
                r = conn.makefile(mode='rb')
                read_data.append(r.read())
                r.close()
                conn.close()
            except:
                server_exc_info.append(sys.exc_info())

        server = Thread(target=accept_and_read)
        client = self.create_connection(**client_args)

        try:
            getattr(client, client_method)(data)
        finally:
            client.shutdown(socket.SHUT_RDWR)
            client.close()

        server.join()
        if match_data is None:
            match_data = self.long_data
        self.assertEqual(read_data[0], match_data)

        if server_exc_info:
            six.reraise(*server_exc_info[0])
Exemplo n.º 2
0
    def _test_sendall(self, data, match_data=None, client_method='sendall',
                      **client_args):

        read_data = []
        server_exc_info = []

        def accept_and_read():
            try:
                conn, _ = self.listener.accept()
                r = conn.makefile(mode='rb')
                read_data.append(r.read())
                r.close()
                conn.close()
            except:
                server_exc_info.append(sys.exc_info())

        server = Thread(target=accept_and_read)
        client = self.create_connection(**client_args)

        try:
            getattr(client, client_method)(data)
        finally:
            client.shutdown(socket.SHUT_RDWR)
            client.close()

        server.join()
        if match_data is None:
            match_data = self.long_data
        self.assertEqual(read_data[0], match_data)

        if server_exc_info:
            six.reraise(*server_exc_info[0])
Exemplo n.º 3
0
 def reraiseFlakyTestRaceCondition():
     six.reraise(FlakyTestRaceCondition,
                 FlakyTestRaceCondition('\n'.join(dump_stacks())),
                 sys.exc_info()[2])
Exemplo n.º 4
0
 def reraiseFlakyTestTimeout():
     six.reraise(FlakyTestTimeout, FlakyTestTimeout(), sys.exc_info()[2])
Exemplo n.º 5
0
def reraiseFlakyTestRaceCondition():
    six.reraise(*sys.exc_info())