title: Mock response with 500 status code in flask and pytest
body: <p><strong>* EDITED*</strong></p>
  
  <p>I would like to test what will happen if external API will return 500 status code.</p>
  
  <pre><code>main.py
  
  @app.route("/&lt;a&gt;/&lt;b&gt;", methods=["GET"])
  def repo_info(a: str, b: str) -&gt; Union[Response, str]:
      info = some_func(a, b)
      result = create_result_dict(some_func)
      return Response(
          response=json.dumps(result, ensure_ascii=False),
          status=200,
          mimetype="application/json",
  
  @app.errorhandler(500)
  def server_error(e):
      logging.exception(f"An error occurred during a request: {e}.")
      return Response(
          response="An internal error occurred. See logs for full stacktrace.",
          status=500,
      )
  </code></pre>
  
  <pre><code>my_module.py
  
  def some_func(a: str, b: str) -&gt; Dict[str, str]:
      return json.loads(
          (requests.get(f"https://api.github.com/repos/{a}/{b}")).text
      )
  </code></pre>
  
  <p>I tried around this code but feel like headless chicken:</p>
  
  <pre><code>from flask import Response
  import pytest
  import requests
  
  from unittest.mock import patch
  from requests.exceptions import HTTPError
  
  @patch.object(my_module, "some_func")
  def test_some_func(mocked):
      mocked.return_value = HTTPError()
      result = my_module.some_func()
      with pytest.raises(HTTPError):
          result == mocked 
  </code></pre>
  
  <p>Also <code>HTTPError</code> doesn't takes arguments, how can I pass information, that I would like 500 status code?</p>