diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/git/test_config.py | 25 | ||||
-rw-r--r-- | test/git/test_repo.py | 9 |
2 files changed, 30 insertions, 4 deletions
diff --git a/test/git/test_config.py b/test/git/test_config.py index c3080fb0..c5a8dc2c 100644 --- a/test/git/test_config.py +++ b/test/git/test_config.py @@ -36,6 +36,29 @@ class TestBase(TestCase): assert w_config._sections w_config.write() # enforce writing assert file_obj.getvalue() == file_obj_orig.getvalue() + + # creating an additional config writer must fail due to exclusive access + self.failUnlessRaises(IOError, GitConfigParser, file_obj, read_only = False) + + # should still have a lock and be able to make changes + assert w_config._has_lock() + + # changes should be written right away + sname = "my_section" + oname = "mykey" + val = "myvalue" + w_config.add_section(sname) + assert w_config.has_section(sname) + w_config.set(sname, oname, val) + assert w_config.has_option(sname,oname) + assert w_config.get(sname, oname) == val + + file_obj.seek(0) + r_config = GitConfigParser(file_obj, read_only=True) + assert r_config.has_section(sname) + assert r_config.has_option(sname, oname) + assert r_config.get(sname, oname) == val + # END for each filename def test_base(self): @@ -64,5 +87,3 @@ class TestBase(TestCase): assert num_sections and num_options assert r_config._is_initialized == True - - self.fail("TODO: Base config writer testing") diff --git a/test/git/test_repo.py b/test/git/test_repo.py index 843a4b4e..0d8a473d 100644 --- a/test/git/test_repo.py +++ b/test/git/test_repo.py @@ -228,6 +228,11 @@ class TestRepo(TestCase): def test_config_writer(self): for config_level in self.repo.config_level: - writer = self.repo.config_writer(config_level) - assert not writer.read_only + try: + writer = self.repo.config_writer(config_level) + assert not writer.read_only + except IOError: + # its okay not to get a writer for some configuration files if we + # have no permissions + pass # END for each config level |