CMSTestCase导致'DatabaseWrapper'对象没有属性'Database'

时间:2015-05-15 10:18:30

标签: python django unit-testing django-cms

我正在尝试用FactoryBoy编写一些简单的测试来测试Django CMS站点上的应用程序。我正在使用Django 1.7.8和django-cms 3.0.13与工厂男孩2.5.2

我最初使用unitest.TestCase设置了测试,然后更改为CMSTestCase,在CMS测试用例下,它只返回AttributeError: 'DatabaseWrapper' object has no attribute 'Database'

运行CMSTestCase时是否需要不同的数据库设置?我的测试没有什么不寻常之处;

from cms.test_utils.testcases import CMSTestCase
from django.core.urlresolvers import reverse
from django.test import Client
from django.test.utils import override_settings

from ...factories import EventFactory, EntrantFactory


class MaxEntrantTest(CMSTestCase):
    def setUp(self):
        self.event = EventFactory.create()
        self.entrants = EntrantFactory.create_batch(self.event.number_of_places)

        # Every test needs a client.
        self.client = Client()

    @override_settings(ROOT_URLCONF='online_entry.tests.test_urls')
    def test_details(self):
        # Issue a GET request.
        response = self.client.get(reverse('online_entry:entry'))

        # Check that the response is 404 event full.
        self.assertEqual(response.status_code, 404)

0 个答案:

没有答案