title: assign mock side_effect to a boto exception and assert calls
body: <p>I have a class that uses boto to download a file from s3, the method uses the <strong>S3Connection</strong> class to initiliase a connection and later on uses the <strong>get_key</strong> method to get the 'file'.
  Here is the code block</p>
  
  <pre><code>import sys
  
  from boto.exception import S3ResponseError, S3DataError
  from boto.s3.connection import S3Connection
  
  class MyClass(object):
      def __init__(self):
          self.s3conn = S3Connection(
                  AWS_ACCESS_KEY_ID,
                  AWS_SECRET_ACCESS_KEY,
                  host=HOST,
                  is_secure=True
          )
          self.bucket = self.s3conn.get_bucket(BUCKET_NAME)
      def get_file(self, key):
          try:
              return self.bucket.get_key(key)
          except (S3ResponseError, S3DataError):
              sys.exit(3)
  </code></pre>
  
  <p>I want to mock out the get_bucket method and give it a side_effect of <strong>S3ResponseError</strong>, so that I can alo mock out the <strong>sys.exit</strong> method and assert it was called.</p>
  
  <p>Here is how I am doing it.</p>
  
  <pre><code>import unittest
  import mock
  from boto.exception import S3ResponseError, S3DataError
  from mymodule import MyClass
  
  class TestS3(unittest.TestCase):
      def setUp(self):
          self.key = 'sample/bubket/key.txt'
          self.myclass = MyClass()
  
      def test_my_method(self):
          exit_method = (
              'mymodule.'
              'sys.'
              'exit'
          )
          s3_get_bucket = (
              'mymodule.'
              'S3Connection.'
              'get_bucket'
          )
  
  
          with mock.patch(s3_get_bucket) as mocked_bucket, \
              mock.patch(exit_method) as mocked_exit:
                  mocked_bucket.side_effect = S3ResponseError
                  self.myclass.get_file(self.key)
                  mocked_exit.assert_called_once_with(3)
  </code></pre>
  
  <p>However, the assertion is failing, any help or guidance is appreciated.</p>
  
  <pre><code>AssertionError: Expected to be called once. Called 0 times.
  </code></pre>