开发者

Stubs for local Django unittests with Google App Engine

开发者 https://www.devze.com 2023-03-09 13:02 出处:网络
I\'d like to run local Django unit tests for a Google App Engine project. GAE recently received some python unit testing utilities that allow one to create stubs for e.g. memcache, the datastore, the

I'd like to run local Django unit tests for a Google App Engine project. GAE recently received some python unit testing utilities that allow one to create stubs for e.g. memcache, the datastore, the task queue, etc.

I'd like to be able to use Django's unit testing framework. My first thought is to overload DjangoTes开发者_开发技巧tSuiteRunner to do the following for each test case:

#     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()

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 django.test.utils.setup_test_environment and teardown_test_environment? What other issues might come up?

Incidentally, I'm not using any Django-GAE helpers such as google-app-engine-django.

Thank you for reading.


Just wanted to mention: standard django unit testing worked very nice for me with django-nonrel and GAE Test Bed, including task-queues, memcache, etc. I think it is the same python unit testing code that you mentioned.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号