title: How can I mock Connection & Timeout Error in Python 3?
body: <p>I am newbie to Python. I am trying to mock exception in my unit test and test my block of code; however exception message is always empty. Is this below recommended way to mock exception? Also how can I make sure exception message is not empty?</p>
  
  <pre><code>import pytest
  import requests
  from unittest.mock import patch
  
  #Unit Test
  @patch('requests.get')
  def test_exception(mock_run):
      mock_run.side_effect = requests.exceptions.ConnectionError()
      with pytest.raises(SystemExit) as sys_exit:
         method_to_test()
      assert 'Error ' in str(sys_exit.value) # Here sys_exit.value is always empty
  
  #Method to Test
  def method_to_test():
      try:
          response = requests.get('some_url', verify=False, stream=True)
          response.raise_for_status()
      except (requests.exceptions.HTTPError,
              requests.exceptions.ConnectionError,
              requests.exceptions.Timeout) as err:
          msg = f'Failure: {err}' # Here err is always empty
          raise SystemExit(msg)
  </code></pre>