• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python config.Config类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中simple_db_migrate.config.Config的典型用法代码示例。如果您正苦于以下问题:Python Config类的具体用法?Python Config怎么用?Python Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Config类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_it_should_raise_exception_for_an_inexistent_config_value_without_specify_a_default_value

 def test_it_should_raise_exception_for_an_inexistent_config_value_without_specify_a_default_value(self):
     config = Config()
     config.put("some_key", "some_value")
     try:
         config.get("ANOTHER_KEY")
     except Exception, e:
         self.assertEqual("invalid key ('another_key')", str(e))
开发者ID:SufianHassan,项目名称:simple-db-migrate,代码行数:7,代码来源:config_test.py


示例2: test_it_should_not_update_saved_config_values

 def test_it_should_not_update_saved_config_values(self):
     config = Config()
     config.put("some_key", "some_value")
     try:
         config.put("some_key", "another_value")
     except Exception, e:
         self.assertEqual("the configuration key 'some_key' already exists and you cannot override any configuration", str(e))
开发者ID:SufianHassan,项目名称:simple-db-migrate,代码行数:7,代码来源:config_test.py


示例3: test_it_should_raise_exception_when_removing_an_inexistent_config_value

 def test_it_should_raise_exception_when_removing_an_inexistent_config_value(self):
     config = Config()
     config.put("some_key", "some_value")
     try:
         config.remove("ANOTHER_KEY")
     except Exception, e:
         self.assertEqual("invalid configuration key ('another_key')", str(e))
开发者ID:SufianHassan,项目名称:simple-db-migrate,代码行数:7,代码来源:config_test.py


示例4: test_it_should_transform_keys_to_lower_case

 def test_it_should_transform_keys_to_lower_case(self):
     config = Config()
     config.put("sOmE_kEy", "original_value")
     self.assertEqual("original_value", config.get("SoMe_KeY"))
     config.update("sOMe_kEy", "new_value")
     self.assertEqual("new_value", config.get("some_KEY"))
     config.remove("SOME_KEY")
     self.assertRaises(Exception, config.get, "sOMe_KEY")
开发者ID:SufianHassan,项目名称:simple-db-migrate,代码行数:8,代码来源:config_test.py


示例5: test_it_should_parse_migrations_dir_with_mixed_relative_and_absolute_dirs

 def test_it_should_parse_migrations_dir_with_mixed_relative_and_absolute_dirs(self):
     dirs = Config._parse_migrations_dir('%s:%s:%s:%s' % ('/tmp/test', '.', './a/relative/path', os.path.abspath('another/path')))
     self.assertEqual(4, len(dirs))
     self.assertEqual('/tmp/test', dirs[0])
     self.assertEqual(os.path.abspath('.'), dirs[1])
     self.assertEqual(os.path.abspath('./a/relative/path'), dirs[2])
     self.assertEqual(os.path.abspath('another/path'), dirs[3])
开发者ID:SufianHassan,项目名称:simple-db-migrate,代码行数:7,代码来源:config_test.py


示例6: test_it_should_parse_migrations_dir_with_multiple_relative_dirs

 def test_it_should_parse_migrations_dir_with_multiple_relative_dirs(self):
     dirs = Config._parse_migrations_dir('test:migrations:./a/relative/path:another/path')
     self.assertEqual(4, len(dirs))
     self.assertEqual(os.path.abspath('test'), dirs[0])
     self.assertEqual(os.path.abspath('migrations'), dirs[1])
     self.assertEqual(os.path.abspath('./a/relative/path'), dirs[2])
     self.assertEqual(os.path.abspath('another/path'), dirs[3])
开发者ID:SufianHassan,项目名称:simple-db-migrate,代码行数:7,代码来源:config_test.py


示例7: test_it_should_parse_migrations_dir_with_relative_dirs_using_config_dir_parameter_as_base_path

 def test_it_should_parse_migrations_dir_with_relative_dirs_using_config_dir_parameter_as_base_path(self):
     dirs = Config._parse_migrations_dir(
             '%s:%s:%s:%s' % ('/tmp/test', '.', './a/relative/path', os.path.abspath('another/path')),
             config_dir='/base/path_to_relative_dirs'
     )
     self.assertEqual(4, len(dirs))
     self.assertEqual('/tmp/test', dirs[0])
     self.assertEqual('/base/path_to_relative_dirs', dirs[1])
     self.assertEqual('/base/path_to_relative_dirs/a/relative/path', dirs[2])
     self.assertEqual(os.path.abspath('another/path'), dirs[3])
开发者ID:SufianHassan,项目名称:simple-db-migrate,代码行数:10,代码来源:config_test.py


示例8: test_it_should_remove_saved_config_values

 def test_it_should_remove_saved_config_values(self):
     config = Config()
     config.put("some_key", "some_value")
     initial = str(config)
     config.remove("some_key")
     self.assertNotEqual(initial, str(config))
开发者ID:SufianHassan,项目名称:simple-db-migrate,代码行数:6,代码来源:config_test.py


示例9: test_it_should_return_previous_saved_config_values

 def test_it_should_return_previous_saved_config_values(self):
     config = Config()
     config.put("some_key", "some_value")
     self.assertEqual("some_value", config.get("some_key"))
开发者ID:SufianHassan,项目名称:simple-db-migrate,代码行数:4,代码来源:config_test.py


示例10: test_it_should_accept_non_empty_string_and_false_as_default_value

 def test_it_should_accept_non_empty_string_and_false_as_default_value(self):
     _dict = {"some_key": "some_value"}
     self.assertEqual(None, Config._get(_dict,"ANOTHER_KEY", None))
     self.assertEqual("", Config._get(_dict,"ANOTHER_KEY", ""))
     self.assertEqual(False, Config._get(_dict,"ANOTHER_KEY", False))
开发者ID:SufianHassan,项目名称:simple-db-migrate,代码行数:5,代码来源:config_test.py


示例11: test_it_should_raise_exception_for_an_inexistent_dict_value_without_specify_a_default_value

 def test_it_should_raise_exception_for_an_inexistent_dict_value_without_specify_a_default_value(self):
     _dict = {"some_key": "some_value"}
     try:
         Config._get(_dict, "ANOTHER_KEY")
     except Exception, e:
         self.assertEqual("invalid key ('ANOTHER_KEY')", str(e))
开发者ID:SufianHassan,项目名称:simple-db-migrate,代码行数:6,代码来源:config_test.py


示例12: test_it_should_return_default_value_for_an_inexistent_dict_value

 def test_it_should_return_default_value_for_an_inexistent_dict_value(self):
     _dict = {"some_key": "some_value"}
     self.assertEqual("default_value", Config._get(_dict, "ANOTHER_KEY", "default_value"))
开发者ID:SufianHassan,项目名称:simple-db-migrate,代码行数:3,代码来源:config_test.py


示例13: test_it_should_return_default_value_for_an_none_dict_value

 def test_it_should_return_default_value_for_an_none_dict_value(self):
     _dict = {"some_key": None}
     self.assertEqual("default_value", Config._get(_dict, "some_key", "default_value"))
开发者ID:SufianHassan,项目名称:simple-db-migrate,代码行数:3,代码来源:config_test.py


示例14: test_it_should_parse_migrations_dir_with_one_relative_dir

 def test_it_should_parse_migrations_dir_with_one_relative_dir(self):
     dirs = Config._parse_migrations_dir('.')
     self.assertEqual(1, len(dirs))
     self.assertEqual(os.path.abspath('.'), dirs[0])
开发者ID:SufianHassan,项目名称:simple-db-migrate,代码行数:4,代码来源:config_test.py


示例15: test_it_should_return_value_from_a_dict_even_if_a_default_value_given

 def test_it_should_return_value_from_a_dict_even_if_a_default_value_given(self):
     _dict = {"some_key": "some_value"}
     self.assertEqual("some_value", Config._get(_dict, "some_key", "default_value"))
开发者ID:SufianHassan,项目名称:simple-db-migrate,代码行数:3,代码来源:config_test.py


示例16: test_it_should_return_value_from_a_dict

 def test_it_should_return_value_from_a_dict(self):
     _dict = {"some_key": "some_value"}
     self.assertEqual("some_value", Config._get(_dict, "some_key"))
开发者ID:SufianHassan,项目名称:simple-db-migrate,代码行数:3,代码来源:config_test.py


示例17: test_it_should_accept_initial_values_as_configuration

 def test_it_should_accept_initial_values_as_configuration(self):
     config = Config({"some_key": "some_value"})
     self.assertEqual("some_value", config.get("some_key"))
开发者ID:SufianHassan,项目名称:simple-db-migrate,代码行数:3,代码来源:config_test.py


示例18: Config

 def test_it_should_update_value_to_a_existing_key_keeping_original_value_if_new_value_is_none_false_or_empty_string(self):
     config = Config()
     config.put("some_key", "original_value")
     config.update("some_key", None)
     self.assertEqual("original_value", config.get("some_key"))
     config.update("some_key", False)
     self.assertEqual("original_value", config.get("some_key"))
     config.update("some_key", "")
     self.assertEqual("original_value", config.get("some_key"))
开发者ID:SufianHassan,项目名称:simple-db-migrate,代码行数:9,代码来源:config_test.py


示例19: test_it_should_update_value_to_a_existing_key

 def test_it_should_update_value_to_a_existing_key(self):
     config = Config()
     config.put("some_key", "original_value")
     config.update("some_key", "some_value")
     self.assertEqual("some_value", config.get("some_key"))
开发者ID:SufianHassan,项目名称:simple-db-migrate,代码行数:5,代码来源:config_test.py


示例20: test_it_should_return_default_value_for_an_inexistent_config_value

 def test_it_should_return_default_value_for_an_inexistent_config_value(self):
     config = Config()
     config.put("some_key", "some_value")
     self.assertEqual("default_value", config.get("another_key", "default_value"))
开发者ID:SufianHassan,项目名称:simple-db-migrate,代码行数:4,代码来源:config_test.py



注:本文中的simple_db_migrate.config.Config类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python testing_utils.create_thread函数代码示例发布时间:2022-05-27
下一篇:
Python cli.CLI类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap