我有一个项目,需要在其中将某些第三方应用程序访问密钥添加到设置模块中,例如AWS密钥。如何为他们编写测试?像下面这样?
def test_it_can_read_aws_keys(self):
assert settings.KEY_1 is None
assert settings.KEY_2 is None
# now somehow i need to add/simulate the keys in settings.py like below
# KEY_1 = 'xxx'
# KEY_2 = 'yyy'
assert settings.KEY_1 is 'xxx'
assert settings.KEY_2 is 'yyy'
答案 0 :(得分:0)
您可以“从django.conf导入设置”导入que设置并测试这些值。但是要小心,请尝试测试Comportament而不是变量的存在。