本文整理汇总了Python中configurations.values.Value类的典型用法代码示例。如果您正苦于以下问题:Python Value类的具体用法?Python Value怎么用?Python Value使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Value类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_env_var_prefix
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')
示例2: test_value_with_default_and_late_binding
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"))
示例3: test_value_reuse
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")
示例4: test_env_var_prefix
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")
示例5: test_env_var
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
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')