# Path: apiritif/http.py
# class RequestFailure(Request):
#     def __init__(self, method, address, request, exc, session):
#         """
# 
#         :type method: str
#         :type address: str
#         :type request: requests.PreparedRequest
#         :type exc: BaseException
#         :type session: requests.Session
#         """
#         response = requests.Response()
#         response.request = request
#         response.status_code = 999
#         response._content = ""
# 
#         super(RequestFailure, self).__init__(method, address, request, HTTPResponse(response), session)
#         self.method = method
#         self.address = address
#         self.request = request
#         self.exception = exc
#         self.session = session
# 
#     def __repr__(self):
#         return "RequestFailure(method=%r, address=%r)" % (self.method, self.address)


import copy
import os
import traceback
import apiritif
from apiritif.http import RequestFailure
        :type recording: list[apiritif.Event]
        :type test_case_sample: Sample
        :rtype: list[Sample]
        """
        self.active_transactions.append(test_case_sample)
        for item in recording:
            if isinstance(item, apiritif.Request):
                self._parse_request(item)
            elif isinstance(item, apiritif.TransactionStarted):
                self._parse_transaction_started(item)
            elif isinstance(item, apiritif.TransactionEnded):
                self._parse_transaction_ended(item)
            elif isinstance(item, apiritif.Assertion):
                self._parse_assertion(item)
            elif isinstance(item, apiritif.AssertionFailure):
                self._parse_assertion_failure(item)
            elif isinstance(item, apiritif.Event):
                self._parse_generic_event(item)
            else:
                raise ValueError("Unknown kind of event in apiritif recording: %s" % item)

        if len(self.active_transactions) != 1:
            # TODO: shouldn't we auto-balance them?
            raise ValueError("Can't parse apiritif recordings: unbalanced transactions")

        toplevel_sample = self.active_transactions.pop()

        return [toplevel_sample]

    def _parse_request(self, item):

# Path: apiritif/http.py
# class RequestFailure(Request):
#     def __init__(self, method, address, request, exc, session):
#         """
# 
#         :type method: str
#         :type address: str
#         :type request: requests.PreparedRequest
#         :type exc: BaseException
#         :type session: requests.Session
#         """
#         response = requests.Response()
#         response.request = request
#         response.status_code = 999
#         response._content = ""
# 
#         super(RequestFailure, self).__init__(method, address, request, HTTPResponse(response), session)
#         self.method = method
#         self.address = address
#         self.request = request
#         self.exception = exc
#         self.session = session
# 
#     def __repr__(self):
#         return "RequestFailure(method=%r, address=%r)" % (self.method, self.address)


# Path: apiritif/samples.py
import copy
import os
import traceback
import apiritif
from apiritif.http import RequestFailure

        :type recording: list[apiritif.Event]
        :type test_case_sample: Sample
        :rtype: list[Sample]
        """
        self.active_transactions.append(test_case_sample)
        for item in recording:
            if isinstance(item, apiritif.Request):
                self._parse_request(item)
            elif isinstance(item, apiritif.TransactionStarted):
                self._parse_transaction_started(item)
            elif isinstance(item, apiritif.TransactionEnded):
                self._parse_transaction_ended(item)
            elif isinstance(item, apiritif.Assertion):
                self._parse_assertion(item)
            elif isinstance(item, apiritif.AssertionFailure):
                self._parse_assertion_failure(item)
            elif isinstance(item, apiritif.Event):
                self._parse_generic_event(item)
            else:
                raise ValueError("Unknown kind of event in apiritif recording: %s" % item)

        if len(self.active_transactions) != 1:
            # TODO: shouldn't we auto-balance them?
            raise ValueError("Can't parse apiritif recordings: unbalanced transactions")

        toplevel_sample = self.active_transactions.pop()

        return [toplevel_sample]

    def _parse_request(self, item):

        is_failure = isinstance(item, RequestFailure)