运行Django测试时如何将DEBUG设置为True? [英] How do you set DEBUG to True when running a Django test?
本文介绍了运行Django测试时如何将DEBUG设置为True?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在运行一些Django测试,默认情况下它看起来是 DEBUG = False
。有没有办法运行特定的测试,我可以在命令行或代码中设置 DEBUG = True
I'm currently running some Django tests and it looks that DEBUG=False
by default. Is there a way to run a specific test where I can set DEBUG=True
at the command line or in code?
推荐答案
对于测试用例中的特定测试,您可以使用override_settings装饰器:
For a specific test inside a test case, you can use the override_settings decorator:
from django.test.utils import override_settings
from django.conf import settings
class TestSomething(TestCase):
@override_settings(DEBUG=True)
def test_debug(self):
assert settings.DEBUG
这篇关于运行Django测试时如何将DEBUG设置为True?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文