Пример #1
0
 def test_check_id(self):
     default_color_id = id(pyrg.PRINT_COLOR_SET_DEFAULT)
     setting_color_id = id(pyrg.PRINT_COLOR_SET)
     get_color_id = id(pyrg.set_configuration(""))
     self.assertNotEqual(default_color_id, setting_color_id)
     self.assertNotEqual(default_color_id, get_color_id)
     self.assertNotEqual(setting_color_id, get_color_id)
Пример #2
0
    def test_config_keyword_notexist_all(self):
        config_example = """
[color]
"""
        temp = NamedTemporaryFile()
        temp.file.write(config_example)
        temp.file.flush()
        color_set = pyrg.set_configuration(temp.name)
        self.assertEqual(pyrg.PRINT_COLOR_SET_DEFAULT, color_set)
        temp.close()
Пример #3
0
    def test_config_empty(self):
        config_example = """
[color]
ok =
error =
fail =
function =
"""
        temp = NamedTemporaryFile()
        temp.file.write(config_example)
        temp.file.flush()
        color_set = pyrg.set_configuration(temp.name)
        self.assertEqual(pyrg.PRINT_COLOR_SET_DEFAULT, color_set)
        temp.close()
Пример #4
0
    def test_config_inval_colorkey(self):
        config_example = """
[color]
ok = white
fail = red
error = jihogeredd
function = pink
"""
        temp = NamedTemporaryFile()
        temp.file.write(config_example)
        temp.file.flush()
        color_set = pyrg.set_configuration(temp.name)
        self.assertEqual('white', color_set['ok'])
        self.assertEqual('yellow', color_set['error'])
        self.assertEqual('red', color_set['fail'])
        self.assertEqual('pink', color_set['function'])
        temp.close()
Пример #5
0
    def test_config(self):
        config_example = """
[color]
ok = yellowgreen
error = red
fail = blue
function = pink
"""
        temp = NamedTemporaryFile()
        temp.file.write(config_example)
        temp.file.flush()
        color_set = pyrg.set_configuration(temp.name)
        self.assertEqual('yellowgreen', color_set['ok'])
        self.assertEqual('red', color_set['error'])
        self.assertEqual('blue', color_set['fail'])
        self.assertEqual('pink', color_set['function'])
        temp.close()
Пример #6
0
 def test_notexist_file(self):
     color_set = pyrg.set_configuration("/home/hogehoge/.pyrgrc")
     self.assertEqual(pyrg.PRINT_COLOR_SET_DEFAULT, color_set)