當前位置: 首頁>>代碼示例>>Python>>正文


Python Conf.get_list方法代碼示例

本文整理匯總了Python中galicaster.core.conf.Conf.get_list方法的典型用法代碼示例。如果您正苦於以下問題:Python Conf.get_list方法的具體用法?Python Conf.get_list怎麽用?Python Conf.get_list使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在galicaster.core.conf.Conf的用法示例。


在下文中一共展示了Conf.get_list方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_get_list

# 需要導入模塊: from galicaster.core.conf import Conf [as 別名]
# 或者: from galicaster.core.conf.Conf import get_list [as 別名]
    def test_get_list(self):
        conf = Conf()
        self.assertEqual(conf.get_list("s", "k"), [])

        conf.set("s", "k", "1 2 3 4 5 6")
        self.assertEqual(conf.get_list("s", "k"), ["1", "2", "3", "4", "5", "6"])

        conf.set("s", "k", "one two three")
        self.assertEqual(conf.get_list("s", "k"), ["one", "two", "three"])
開發者ID:rubenrua,項目名稱:Galicaster,代碼行數:11,代碼來源:conf.py

示例2: TestFunctions

# 需要導入模塊: from galicaster.core.conf import Conf [as 別名]
# 或者: from galicaster.core.conf.Conf import get_list [as 別名]

#.........這裏部分代碼省略.........
        self.conf.set('s', 'k', 1)
        self.assertFalse(self.conf.get_boolean('s', 'k', False))

    def test_get_lower(self):
        for lower in ['RUBENRUA', 'RubenRua', 'RubenruA', 'rubenrua']:
            self.conf.set('s', 'k', lower)
            self.assertEqual(self.conf.get_lower('s', 'k'), 'rubenrua')

        self.assertEqual(self.conf.get_lower('s', 'k_not_exists', None), None)

        self.conf.set('s', 'k', 'TEST')
        self.assertEqual(self.conf.get_lower('s', 'k'), 'test')

        self.conf.set('s', 'k2', 1234)
        self.assertEqual(self.conf.get_lower('s', 'k2', 'testing'), 'testing')


    def test_get_int(self):
        self.conf.set('s', 'k', '10')
        self.assertEqual(self.conf.get_int('s', 'k'), 10)

        self.conf.set('s', 'k2', 'test')
        self.assertEqual(self.conf.get_int('s', 'k2', 20), 20)


    def test_get_hour(self):
        self.conf.set('s', 'k', '12:34')
        self.assertEqual(self.conf.get_hour('s', 'k'), '12:34')

        self.conf.set('s', 'k2', 'test')
        self.assertEqual(self.conf.get_hour('s', 'k2', '11:11'), '11:11')


    def test_get_list(self):
        self.assertEqual(self.conf.get_list('s', 'k'), [])

        self.conf.set('s', 'k', '1 2 3 4 5 6')
        self.assertEqual(self.conf.get_list('s', 'k'), ['1', '2', '3', '4', '5', '6'])

        self.conf.set('s', 'k', 'one two three')
        self.assertEqual(self.conf.get_list('s', 'k'), ['one', 'two', 'three'])


    def test_get_choice(self):
        self.assertEqual(self.conf.get_choice('s', 'k', ['1','2','3'], '2'), '2')

        self.conf.set('s', 'k', '1')
        self.assertEqual(self.conf.get_choice('s', 'k', ['1','2','3']), '1')

        self.conf.set('s', 'k', 'TEST')
        self.assertEqual(self.conf.get_choice('s', 'k', ['1','2','3', 'test']), 'test')


    def test_get_choice_uppercase(self):
        self.assertEqual(self.conf.get_choice_uppercase('s', 'k', ['1','2','3'], '2'), '2')

        self.conf.set('s', 'k', '1')
        self.assertEqual(self.conf.get_choice_uppercase('s', 'k', ['1','2','3']), '1')

        self.conf.set('s', 'k', 'test')
        self.assertEqual(self.conf.get_choice_uppercase('s', 'k', ['1','2','3', 'TEST']), 'TEST')


    def test_get_dict(self):
        self.assertEqual(self.conf.get_dict('s', 'k'), {})
開發者ID:SussexLearningSystems,項目名稱:Galicaster,代碼行數:69,代碼來源:conf.py


注:本文中的galicaster.core.conf.Conf.get_list方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。