docs: def record(cls, filename, indentation=4, encoding='utf-8'):
          """
          .. testcode::
  
             import io
             import json
             import requests
             import httpretty
  
             with httpretty.record('/tmp/ip.json'):
                 data = requests.get('https://httpbin.org/ip').json()
  
             with io.open('/tmp/ip.json') as fd:
                 assert data == json.load(fd)
  
          :param filename: a string
          :param indentation: an integer, defaults to **4**
          :param encoding: a string, defaults to **"utf-8"**
  
          :returns: a `context-manager <https://docs.python.org/3/reference/datamodel.html#context-managers>`_
          """
          try:
              import urllib3
          except ImportError:
              msg = (
                  'HTTPretty requires urllib3 installed '
                  'for recording actual requests.'
              )
              raise RuntimeError(msg)
  
          http = urllib3.PoolManager()
  
          cls.enable()
          calls = []
  
          def record_request(request, uri, headers):
              cls.disable()
  
              kw = {}
              kw.setdefault('body', request.body)
              kw.setdefault('headers', dict(request.headers))
              response = http.request(request.method, uri, **kw)
              calls.append({
                  'request': {
                      'uri': uri,
                      'method': request.method,
                      'headers': dict(request.headers),
                      'body': decode_utf8(request.body),
                      'querystring': request.querystring
                  },
                  'response': {
                      'status': response.status,
                      'body': decode_utf8(response.data),
                      # urllib3 1.10 had a bug if you just did:
                      # dict(response.headers)
                      # which would cause all the values to become lists
                      # with the header name as the first item and the
                      # true value as the second item. Workaround that
                      'headers': dict(response.headers.items())
                  }
              })
              cls.enable()
              return response.status, response.headers, response.data
  
          for method in cls.METHODS:
              cls.register_uri(method, MULTILINE_ANY_REGEX, body=record_request)
  
          yield
          cls.disable()
          with codecs.open(filename, 'w', encoding) as f:
              f.write(json.dumps(calls, indent=indentation))