title: Stubs for local Django unittests with Google App Engine
body: <p>I'd like to run local Django unit tests for a Google App Engine project. GAE recently received some <a href="http://code.google.com/appengine/docs/python/tools/localunittesting.html" rel="nofollow"><code>python unit testing utilities</code></a> that allow one to create stubs for e.g. memcache, the datastore, the task queue, etc.</p>
  
  <p>I'd like to be able to use Django's unit testing framework. My first thought is to overload <a href="https://docs.djangoproject.com/en/dev/topics/testing" rel="nofollow"><code>DjangoTestSuiteRunner</code></a> to do the following for each test case:</p>
  
  <pre><code>#     setUp
  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_datastore_v3_stub()
  self.testbed.init_memcache_stub()
  
  # ... after tests:
  #
  #     Teardown
  self.testbed.deactivate()
  </code></pre>
  
  <p>I'd like to know if anyone else has tried to run Django's testing framework with the new unittests that can be run from the command line for GAE, and if so what pitfalls they've encountered. For example, are there any issues with calling Django's <code>django.test.utils.setup_test_environment</code> and <code>teardown_test_environment</code>? What other issues might come up?</p>
  
  <p>Incidentally, I'm not using any Django-GAE helpers such as <a href="http://code.google.com/p/google-app-engine-django/" rel="nofollow">google-app-engine-django</a>.</p>
  
  <p>Thank you for reading.</p>