From c24c720b6135a8f7975bf9af265124eee2d464cb Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 2 Jul 2009 16:12:57 -0700 Subject: 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 --- tests/test_git_config.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/test_git_config.py') diff --git a/tests/test_git_config.py b/tests/test_git_config.py index d67a8bab..5b1770e7 100644 --- a/tests/test_git_config.py +++ b/tests/test_git_config.py @@ -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() -- cgit v1.2.3-54-g00ecf