本地Django测试用谷歌应用程序引擎的存根

时间:2021-10-26 23:13:36

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.

我想为谷歌应用程序引擎项目运行本地Django单元测试。GAE最近收到了一些python单元测试实用程序,允许为memcache、datastore、任务队列等创建存根。

I'd like to be able to use Django's unit testing framework. My first thought is to overload DjangoTestSuiteRunner to do the following for each test case:

我希望能够使用Django的单元测试框架。我的第一个想法是重载DjangoTestSuiteRunner,对每个测试用例执行以下操作:

#     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?

我想知道是否有其他人尝试使用新的unittests来运行Django的测试框架,这些测试可以从GAE的命令行运行,如果有的话,他们遇到了哪些缺陷。例如,调用Django的Django .test.utils是否存在问题。setup_test_environment teardown_test_environment ?还会出现什么问题?

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

顺便说一句,我没有使用任何Django-GAE助手,比如google-app-engine-django。

Thank you for reading.

感谢您的阅读。

1 个解决方案

#1


1  

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.

我只想提一下:对于django-nonrel和GAE测试平台,标准django单元测试非常适合我,包括任务队列、memcache等。

#1


1  

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.

我只想提一下:对于django-nonrel和GAE测试平台,标准django单元测试非常适合我,包括任务队列、memcache等。