def __call__(self, result=None):
   """
   Intitializes the appengine sdk service stubs, doing setup here
   means subclasses don't have to call super.setUp.
   """
   try:
     self._pre_setup()
     FlaskTestCase.__call__(self, result)
   finally:
     self._post_teardown()
  def setUp(self):
    '''Base setUp intitializes the appengine sdk service stubs.'''
    FlaskTestCase.setUp(self)
    # First, create an instance of the Testbed class.
    self.testbed = testbed.Testbed()
    # Then activate the testbed, which prepares the
    # service stubs for use
    self.testbed.activate()
    # Next, declare which service stubs you want to use.
    self.testbed.init_mail_stub()
    self.testbed.init_xmpp_stub()
    self.testbed.init_files_stub()
    # if PIL is not installed this will raise..
    try:
      import PIL
      self.testbed.init_images_stub()
    except ImportError:
      pass
    except testbed.StubNotSupportedError:
      pass
    self.testbed.init_channel_stub()
    self.testbed.init_memcache_stub()
    self.testbed.init_urlfetch_stub()
    self.testbed.init_blobstore_stub()
    self.testbed.init_taskqueue_stub()
    self.testbed.init_capability_stub()
    self.testbed.init_logservice_stub()
    self.testbed.init_app_identity_stub()
    self.testbed.init_datastore_v3_stub()

    try:
      from google.appengine.api.search.simple_search_stub import SearchServiceStub
      self.testbed._register_stub('search', SearchServiceStub())
    except ImportError:
      pass
    except testbed.StubNotSupportedError:
      pass