【发布时间】:2021-01-09 01:53:58
【问题描述】:
这个问题类似于another question here on stack overflow。
我正在使用 Django's StaticLiveServerTestCase 向我的 wagtail 网站添加测试。下面是我手头的代码库示例:
class ExampleTest(StaticLiveServerTestCase):
def setUp(self):
self.browser = webdriver.Chrome()
def test_example_test(self):
self.assertContains("Contact Page", self.browser.content)
[...]
因此,当我使用 python manage.py test 运行此测试时,测试失败,因为出现 500 错误。 请记住,我使用的是 wagtail 而不是单独使用 Vanilla Django。我还使用 Django 的 Site 框架,而不是 Wagtail 的 Site 框架,因为 allauth 只允许与 Django 的 Site 框架一起使用。
将@override_settings(DEBUG=True) 应用到这样的测试后:
@override_settings(DEBUG=True)
class ExampleTest(StaticLiveServerTestCase):
def setUp(self):
self.browser = webdriver.Chrome()
def test_example_test(self):
self.assertContains("Contact Page", self.browser.content)
[...]
测试仍然失败,因为正在加载的页面是 wagtail 默认页面。
我的问题是,我如何将另一个页面设置为根/默认 wagtail 页面,以便当对 localhost:8000 [或测试服务器提供的任何其他端口号] 的请求是进入主页(即 http://localhost:8000/),我看到的是新页面而不是 wagtail 默认页面?
谢谢。
【问题讨论】:
标签: wagtail