本文整理汇总了Python中types.ModuleType.SECRET_KEY方法的典型用法代码示例。如果您正苦于以下问题:Python ModuleType.SECRET_KEY方法的具体用法?Python ModuleType.SECRET_KEY怎么用?Python ModuleType.SECRET_KEY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类types.ModuleType
的用法示例。
在下文中一共展示了ModuleType.SECRET_KEY方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_settings_init_warning
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import SECRET_KEY [as 别名]
def test_settings_init_warning(self):
settings_module = ModuleType('fake_settings_module')
settings_module.DEFAULT_CONTENT_TYPE = 'text/xml'
settings_module.SECRET_KEY = 'abc'
sys.modules['fake_settings_module'] = settings_module
try:
with self.assertRaisesMessage(RemovedInDjango30Warning, self.msg):
Settings('fake_settings_module')
finally:
del sys.modules['fake_settings_module']
示例2: test_secret_key_empty_string
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import SECRET_KEY [as 别名]
def test_secret_key_empty_string(self):
settings_module = ModuleType('fake_settings_module')
settings_module.SECRET_KEY = ''
sys.modules['fake_settings_module'] = settings_module
try:
msg = 'The SECRET_KEY setting must not be empty.'
with self.assertRaisesMessage(ImproperlyConfigured, msg):
Settings('fake_settings_module')
finally:
del sys.modules['fake_settings_module']
示例3: test_settings_init_warning
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import SECRET_KEY [as 别名]
def test_settings_init_warning(self):
settings_module = ModuleType('fake_settings_module')
settings_module.FILE_CHARSET = 'latin1'
settings_module.SECRET_KEY = 'ABC'
sys.modules['fake_settings_module'] = settings_module
try:
with self.assertRaisesMessage(RemovedInDjango31Warning, self.msg):
Settings('fake_settings_module')
finally:
del sys.modules['fake_settings_module']
示例4: test_module
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import SECRET_KEY [as 别名]
def test_module(self):
settings_module = ModuleType('fake_settings_module')
settings_module.SECRET_KEY = 'foo'
sys.modules['fake_settings_module'] = settings_module
try:
s = Settings('fake_settings_module')
self.assertTrue(s.is_overridden('SECRET_KEY'))
self.assertFalse(s.is_overridden('ALLOWED_HOSTS'))
finally:
del sys.modules['fake_settings_module']
示例5: test_tuple_settings
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import SECRET_KEY [as 别名]
def test_tuple_settings(self):
settings_module = ModuleType('fake_settings_module')
settings_module.SECRET_KEY = 'foo'
for setting in self.tuple_settings:
setattr(settings_module, setting, ('non_tuple_value'))
sys.modules['fake_settings_module'] = settings_module
try:
with self.assertRaises(ImproperlyConfigured):
Settings('fake_settings_module')
finally:
del sys.modules['fake_settings_module']
delattr(settings_module, setting)