def force_content_type_jsonapi(test_client):
 def set_content_type(func):
  'Returns a decorated version of ``func``, as described in the\n        wrapper defined below.\n\n        '
  @wraps(func)
  def new_func(*args, **kw):
   'Sets the correct :http:header:`Content-Type` headers\n            before executing ``func(*args, **kw)``.\n\n            '
   if ('headers' not in kw):
    kw['headers'] = dict()
   headers = kw['headers']
   if (('content_type' not in kw) and ('Content-Type' not in headers)):
    kw['content_type'] = JSONAPI_MIMETYPE
   return func(*args, **kw)
  return new_func
 test_client.patch = set_content_type(test_client.patch)
 test_client.post = set_content_type(test_client.post)

def force_content_type_jsonapi ( test_client ) : def set_content_type ( func ) : @ wraps ( func ) def new_func ( * args , ** kw ) : if ( 'headers' not in kw ) : kw [ 'headers' ] = dict ( ) headers = kw [ 'headers' ] if ( ( 'content_type' not in kw ) and ( 'Content-Type' not in headers ) ) : kw [ 'content_type' ] = JSONAPI_MIMETYPE return func ( * args , ** kw ) return new_func test_client . patch = set_content_type ( test_client . patch ) test_client . post = set_content_type ( test_client . post )
ensures that all requests made by the specified flask test client that include data have the correct :http:header:content-type header .