blob: 9fc4b6cf6d5bfea7ad25f2b76cb3acb84eb5a93b [file] [log] [blame]
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Unit tests for site_utils/"""
import logging, mox, os, tempfile, unittest
import forgiving_config_parser
class ForgivingConfigParserTest(mox.MoxTestBase):
def setUp(self):
super(ForgivingConfigParserTest, self).setUp()
self._tmpconfig = tempfile.NamedTemporaryFile()
def testReRead(self):
"""Test that we reread() loads the same config file over again."""
section = 'first'
option1 = 'option1'
value1 = 'value1'
option2 = 'option2'
value2 = 'value2'
# Create initial file.
initial = forgiving_config_parser.ForgivingConfigParser()
initial.set(section, option1, value1)
with open(, 'w') as conf_file:
to_test = forgiving_config_parser.ForgivingConfigParser()
self.assertEquals(value1, to_test.getstring(section, option1))
self.assertEquals(None, to_test.getstring(section, option2))
initial.set(section, option2, value2)
initial.remove_option(section, option1)
with open(, 'w') as conf_file:
self.assertEquals(None, to_test.getstring(section, option1))
self.assertEquals(value2, to_test.getstring(section, option2))