def reraiseFlakyTestRaceCondition(): if sysinfo.PYPY and sysinfo.WIN: # Getting stack traces is incredibly expensive # in pypy on win, at least in test virtual machines. # It can take minutes. The traceback consistently looks like # the following when interrupted: # dump_stacks -> traceback.format_stack # -> traceback.extract_stack -> linecache.checkcache # -> os.stat -> _structseq.structseq_new msg = str(sys.exc_info()[1]) else: msg = '\n'.join(dump_stacks()) six.reraise(FlakyTestRaceCondition, FlakyTestRaceCondition(msg), sys.exc_info()[2])
def _test_sendall(self, data, match_data=None, client_method='sendall', **client_args): read_data = [] server_exc_info = [] def accept_and_read(): conn = None try: conn, _ = self.listener.accept() r = conn.makefile(mode='rb') read_data.append(r.read()) r.flush() r.close() except: # pylint:disable=bare-except server_exc_info.append(sys.exc_info()) finally: if conn: conn.close() self.listener.close() 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])
def reraiseFlakyTestTimeout(): six.reraise(FlakyTestTimeout, FlakyTestTimeout(), sys.exc_info()[2])
def reraiseFlakyTestRaceCondition(): six.reraise(FlakyTestRaceCondition, FlakyTestRaceCondition('\n'.join(dump_stacks())), sys.exc_info()[2])
def reraiseFlakyTestRaceCondition(): six.reraise(*sys.exc_info())
def reraiseFlakyTestTimeout(): msg = str(sys.exc_info()[1]) six.reraise(FlakyTestTimeout, FlakyTestTimeout(msg), sys.exc_info()[2])
def reraiseFlakyTestRaceCondition(): six.reraise(FlakyAssertionError, FlakyAssertionError(sys.exc_info()[1]), sys.exc_info()[2])