本文整理汇总了Python中configurations.values.Value.setup方法的典型用法代码示例。如果您正苦于以下问题:Python Value.setup方法的具体用法?Python Value.setup怎么用?Python Value.setup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类configurations.values.Value
的用法示例。
在下文中一共展示了Value.setup方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_value_reuse
# 需要导入模块: from configurations.values import Value [as 别名]
# 或者: from configurations.values.Value import setup [as 别名]
def test_value_reuse(self):
value1 = Value("default")
value2 = Value(value1)
self.assertEqual(value1.setup("TEST1"), "default")
self.assertEqual(value2.setup("TEST2"), "default")
with env(DJANGO_TEST1="override1", DJANGO_TEST2="override2"):
self.assertEqual(value1.setup("TEST1"), "override1")
self.assertEqual(value2.setup("TEST2"), "override2")
示例2: test_env_var_prefix
# 需要导入模块: from configurations.values import Value [as 别名]
# 或者: from configurations.values.Value import setup [as 别名]
def test_env_var_prefix(self):
with patch.dict(os.environ, clear=True, ACME_TEST='override'):
value = Value('default', environ_prefix='ACME')
self.assertEqual(value.setup('TEST'), 'override')
with patch.dict(os.environ, clear=True, TEST='override'):
value = Value('default', environ_prefix='')
self.assertEqual(value.setup('TEST'), 'override')
示例3: test_env_var_prefix
# 需要导入模块: from configurations.values import Value [as 别名]
# 或者: from configurations.values.Value import setup [as 别名]
def test_env_var_prefix(self):
with patch.dict(os.environ, clear=True, ACME_TEST="override"):
value = Value("default", environ_prefix="ACME")
self.assertEqual(value.setup("TEST"), "override")
with patch.dict(os.environ, clear=True, TEST="override"):
value = Value("default", environ_prefix="")
self.assertEqual(value.setup("TEST"), "override")
with patch.dict(os.environ, clear=True, ACME_TEST="override"):
value = Value("default", environ_prefix="ACME_")
self.assertEqual(value.setup("TEST"), "override")
示例4: test_value_with_default_and_late_binding
# 需要导入模块: from configurations.values import Value [as 别名]
# 或者: from configurations.values.Value import setup [as 别名]
def test_value_with_default_and_late_binding(self):
value = Value("default", environ=False, late_binding=True)
self.assertEqual(type(value), Value)
with env(DJANGO_TEST="override"):
self.assertEqual(value.setup("TEST"), "default")
value = Value(environ_name="TEST")
self.assertEqual(type(value), type("override"))
self.assertEqual(value, "override")
self.assertEqual(str(value), "override")
self.assertEqual("{0}".format(value), "override")
self.assertEqual("%s" % value, "override")
value = Value(environ_name="TEST", late_binding=True)
self.assertEqual(type(value), Value)
self.assertEqual(value.value, "override")
self.assertEqual(str(value), "override")
self.assertEqual("{0}".format(value), "override")
self.assertEqual("%s" % value, "override")
self.assertEqual(repr(value), repr("override"))
示例5: test_env_var
# 需要导入模块: from configurations.values import Value [as 别名]
# 或者: from configurations.values.Value import setup [as 别名]
def test_env_var(self):
value = Value("default")
self.assertEqual(value.setup("TEST"), "override")
self.assertEqual(str(value), "override")
self.assertNotEqual(value.setup("TEST"), value.default)
self.assertEqual(value.to_python(os.environ["DJANGO_TEST"]), value.setup("TEST"))
示例6: test_value
# 需要导入模块: from configurations.values import Value [as 别名]
# 或者: from configurations.values.Value import setup [as 别名]
def test_value(self):
value = Value('default', environ=False)
self.assertEqual(value.setup('TEST'), 'default')
with env(DJANGO_TEST='override'):
self.assertEqual(value.setup('TEST'), 'default')