summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Aguilar <davvid@gmail.com>2009-06-28 15:09:16 -0700
committerDavid Aguilar <davvid@gmail.com>2009-06-29 00:24:36 -0700
commit438c54713a7ca56fba2a7985b6563aa076b17169 (patch)
treecdb2d8cfd5e05d3659f9b7bc9c5a5191d322df5f /tests
parente020ebee4e3e4e2ddefd72d41ac0035e6d528725 (diff)
downloadgit-repo-438c54713a7ca56fba2a7985b6563aa076b17169.tar.gz
git_config: handle configuration entries with no values
A git-config entry with no value was preventing repo from initializing. This modifies _ReadGit() to handle config entries with empty values. Signed-off-by: David Aguilar <davvid@gmail.com> Reported-by: Josh Guilfoyle <jasta00@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/fixtures/test.gitconfig3
-rw-r--r--tests/test_git_config.py43
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/fixtures/test.gitconfig b/tests/fixtures/test.gitconfig
new file mode 100644
index 00000000..3c573c9e
--- /dev/null
+++ b/tests/fixtures/test.gitconfig
@@ -0,0 +1,3 @@
1[section]
2 empty
3 nonempty = true
diff --git a/tests/test_git_config.py b/tests/test_git_config.py
new file mode 100644
index 00000000..d67a8bab
--- /dev/null
+++ b/tests/test_git_config.py
@@ -0,0 +1,43 @@
1import os
2import unittest
3
4import git_config
5
6def fixture(*paths):
7 """Return a path relative to test/fixtures.
8 """
9 return os.path.join(os.path.dirname(__file__), 'fixtures', *paths)
10
11class GitConfigUnitTest(unittest.TestCase):
12 """Tests the GitConfig class.
13 """
14 def setUp(self):
15 """Create a GitConfig object using the test.gitconfig fixture.
16 """
17 config_fixture = fixture('test.gitconfig')
18 self.config = git_config.GitConfig(config_fixture)
19
20 def test_GetString_with_empty_config_values(self):
21 """
22 Test config entries with no value.
23
24 [section]
25 empty
26
27 """
28 val = self.config.GetString('section.empty')
29 self.assertEqual(val, None)
30
31 def test_GetString_with_true_value(self):
32 """
33 Test config entries with a string value.
34
35 [section]
36 nonempty = true
37
38 """
39 val = self.config.GetString('section.nonempty')
40 self.assertEqual(val, 'true')
41
42if __name__ == '__main__':
43 unittest.main()