class TestConfig(unittest.TestCase):
    def setUp(self):
        help_set_up()
        self.my_config = Config(test_configfile_path)

    def test_Config___init__(self):
        my_config2 = Config(test_configfile_path)
        self.assertIsInstance(my_config2, Config)
        self.assertIsInstance(my_config2, ConfigParserWithComments)
        self.assertEqual(my_config2.configfile_path, test_configfile_path)

    def test_Config_write_configfile(self):
        # order matters
        self.assertFalse(os.path.isfile(test_configfile_path))
        self.my_config.write_configfile()
        self.assertTrue(os.path.isfile(test_configfile_path))
        with open(test_configfile_path, 'rb') as configfile:
            self.assertEqual(configfile.read(), '# -*- task_manage_zfb: true -*-\n')
        self.assertEqual(os.path.getsize(test_configfile_path), 32L)

    def test_Config_write_configfile2(self):
        # order matters
        self.assertFalse(os.path.isfile(test_configfile_path))
        self.my_config.set_start_comment('# sth to comment')
        self.my_config.write_configfile()
        self.assertTrue(os.path.isfile(test_configfile_path))
        with open(test_configfile_path, 'rb') as configfile:
            self.assertEqual(configfile.read(), '# -*- task_manage_zfb: true -*-\n# sth to comment\n')
        self.assertEqual(os.path.getsize(test_configfile_path), 49L)

    def test_Config_is_config_file(self):
        self.my_config.write_configfile()
        self.assertFalse(Config.is_config_file(normalfile_path))
        self.assertTrue(Config.is_config_file(test_configfile_path))

    def test_Config_del_configfile(self):
        self.my_config.write_configfile()
        self.assertTrue(os.path.isfile(test_configfile_path))
        self.my_config.del_configfile()
        self.assertFalse(os.path.isfile(test_configfile_path))

    def test_Config_del_configfile_raises_error(self):
        self.assertTrue(os.path.isfile(normalfile_path))
        self.assertRaises(ConfigNotConfigFileError, self.my_config.del_configfile, normalfile_path)
        self.assertTrue(os.path.isfile(normalfile_path))

    def tearDown(self):
        help_tear_down()
 def setUp(self):
     help_set_up()
     self.my_config = Config(test_configfile_path)
 def test_Config_is_config_file(self):
     self.my_config.write_configfile()
     self.assertFalse(Config.is_config_file(normalfile_path))
     self.assertTrue(Config.is_config_file(test_configfile_path))