ape*_*ari 14 python django debugging selenium traceback
我正在用Selenium写一些测试.
当我运行我的selenium测试(LiveServerTestCase类型)并且我的代码中有一些错误(不是在测试中,我的意思是在执行的代码中,就像我用selenium到达的主页视图)我得到500模板(通常我得到的时候)我有DEBUG = False)即使我有:
DEBUG = True
INTERNAL_IPS = ('127.0.0.1',)
Run Code Online (Sandbox Code Playgroud)
我坚持这一点,我不明白为什么我的测试失败(因为在公众500我没有显示例外).
为什么它表现得那样?我在哪里可以解决?
当我运行runserver时它完美运行(我得到回溯).
ape*_*ari 17
来自django docs https://docs.djangoproject.com/en/1.4/topics/testing/#other-test-conditions
现在似乎无法覆盖这一点,即使使用https://docs.djangoproject.com/en/1.4/topics/testing/#django.test.utils.override_settings
在返回500响应时查看调试信息的唯一方法是记录它.
编辑:我找到了一种DEBUG = True在我的硒测试中设置的方法.在我的子类中,我重写构造函数并更改设置.
from django.conf import settings
class SeleniumLiveServerTestCase(LiveServerTestCase):
def __init__(self, *args, **kwargs):
super(SeleniumLiveServerTestCase, self).__init__(*args, **kwargs)
if settings.DEBUG == False:
settings.DEBUG = True
Run Code Online (Sandbox Code Playgroud)
它很丑,但有效!
我遇到了同样的问题,现在可以覆盖设置.
根据您的示例,您将导入override_settings并将装饰器放在类的上方:
from django.test import override_settings
@override_settings(DEBUG=True)
class SeleniumLiveServerTestCase(LiveServerTestCase):
...
Run Code Online (Sandbox Code Playgroud)
django docs中的详细信息
| 归档时间: |
|
| 查看次数: |
2555 次 |
| 最近记录: |