在Google App Engine上对Django进行单元测试

时间:2013-12-12 10:23:58

标签: django google-app-engine unit-testing django-unittest

我在GAE上运行django单元测试时遇到了困难。我可能会错误地设置它。

from django.test import TestCase
from django.test.utils import setup_test_environment
from django.test.client import Client

class Test_base(TestCase):

    def setUp(self):
        self.client = Client()
        # 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_datastore_v3_stub()
        self.testbed.init_mail_stub()
        self.testbed.init_memcache_stub()
        setup_test_environment()

    def tearDown(self):
        self.testbed.deactivate()


from test_base import Test_base
from nose.tools.trivial import eq_

class TestModels(Test_base):
    def test_shout_exists(self):
        eq_(1,2)

运行test_shout_exists单元测试时,收到以下错误消息:

Finding files... done.
Importing test modules ... done.

Error: Couldn't install apps, because there were errors in one or more models:
django.contrib.contenttypes: 'module' object has no attribute 'messages'
django.contrib.messages: No module named messages
django.contrib.admin: 'module' object has no attribute 'messages'
django.contrib.auth: 'module' object has no attribute 'messages'
django.contrib.staticfiles: No module named staticfiles
django.contrib.sessions: 'module' object has no attribute 'messages'

任何提示?感谢

0 个答案:

没有答案