diff options
author | Craig Northway <craig.northway@gmail.com> | 2014-07-25 11:26:48 +1000 |
---|---|---|
committer | Craig Northway <craig.northway@gmail.com> | 2014-07-25 19:19:22 +1000 |
commit | a23d0d8617ba3119069e610fc7b0850a17322726 (patch) | |
tree | d8bc5213dd7e7c7f0befdf65afecb13d5435f873 /git/test/test_config.py | |
parent | 75194159abce545bfa38c3172efb42da9b0017dc (diff) | |
download | gitpython-a23d0d8617ba3119069e610fc7b0850a17322726.tar.gz |
Autopep8 fixes with maximum line length 120
Diffstat (limited to 'git/test/test_config.py')
-rw-r--r-- | git/test/test_config.py | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/git/test/test_config.py b/git/test/test_config.py index b37db290..b00240b0 100644 --- a/git/test/test_config.py +++ b/git/test/test_config.py @@ -10,36 +10,37 @@ from git.config import * from copy import copy from ConfigParser import NoSectionError + class TestConfig(TestBase): - + def _to_memcache(self, file_path): fp = open(file_path, "r") sio = StringIO.StringIO(fp.read()) sio.name = file_path return sio - + def _parsers_equal_or_raise(self, lhs, rhs): pass - + def test_read_write(self): # writer must create the exact same file as the one read before for filename in ("git_config", "git_config_global"): file_obj = self._to_memcache(fixture_path(filename)) file_obj_orig = copy(file_obj) - w_config = GitConfigParser(file_obj, read_only = False) + w_config = GitConfigParser(file_obj, read_only=False) w_config.read() # enforce reading assert w_config._sections w_config.write() # enforce writing - + # we stripped lines when reading, so the results differ 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) - + self.failUnlessRaises(IOError, GitConfigParser, file_obj, read_only=False) + # should still have a lock and be able to make changes assert w_config._lock._has_lock() - + # changes should be written right away sname = "my_section" oname = "mykey" @@ -47,23 +48,23 @@ class TestConfig(TestBase): 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.has_option(sname, oname) assert w_config.get(sname, oname) == val - + sname_new = "new_section" oname_new = "new_key" ival = 10 w_config.set_value(sname_new, oname_new, ival) assert w_config.get_value(sname_new, oname_new) == ival - + file_obj.seek(0) r_config = GitConfigParser(file_obj, read_only=True) - #print file_obj.getvalue() + # print file_obj.getvalue() 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): path_repo = fixture_path("git_config") path_global = fixture_path("git_config_global") @@ -71,7 +72,7 @@ class TestConfig(TestBase): assert r_config.read_only num_sections = 0 num_options = 0 - + # test reader methods assert r_config._is_initialized == False for section in r_config.sections(): @@ -84,27 +85,27 @@ class TestConfig(TestBase): assert val assert "\n" not in option assert "\n" not in val - + # writing must fail self.failUnlessRaises(IOError, r_config.set, section, option, None) - self.failUnlessRaises(IOError, r_config.remove_option, section, option ) + self.failUnlessRaises(IOError, r_config.remove_option, section, option) # END for each option self.failUnlessRaises(IOError, r_config.remove_section, section) - # END for each section + # END for each section assert num_sections and num_options assert r_config._is_initialized == True - + # get value which doesnt exist, with default default = "my default value" assert r_config.get_value("doesnt", "exist", default) == default - + # it raises if there is no default though self.failUnlessRaises(NoSectionError, r_config.get_value, "doesnt", "exist") - + def test_values(self): file_obj = self._to_memcache(fixture_path("git_config_values")) - w_config = GitConfigParser(file_obj, read_only = False) - w_config.write() # enforce writing + w_config = GitConfigParser(file_obj, read_only=False) + w_config.write() # enforce writing orig_value = file_obj.getvalue() # Reading must unescape backslashes @@ -122,7 +123,7 @@ class TestConfig(TestBase): # Writing must escape backslashes and quotes w_config.set('values', 'backslash', backslash) w_config.set('values', 'quote', quote) - w_config.write() # enforce writing + w_config.write() # enforce writing # Contents shouldn't differ assert file_obj.getvalue() == orig_value |