Fix error parsing a non-existant configuration file

If a file (e.g. ~/.gitconfig) does not exist, we get None
here rather than a string.  NoneType lacks rstrip() so we
cannot strip it.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce committed 2009-07-02 16:12:57 -07:00
1 parent 2d1a396897
commit c24c720b61
2 files changed
+13 -2

No files matched your search

+9
View File
@@ -39,5 +39,14 @@ class GitConfigUnitTest(unittest.TestCase):
val = self.config.GetString('section.nonempty')
self.assertEqual(val, 'true')
def test_GetString_from_missing_file(self):
"""
Test missing config file
"""
config_fixture = fixture('not.present.gitconfig')
config = git_config.GitConfig(config_fixture)
val = config.GetString('empty')
self.assertEqual(val, None)
if __name__ == '__main__':
unittest.main()