4 from cola
import gitcfg
7 class GitConfigTestCase(helper
.GitRepositoryTestCase
):
8 """Tests the cola.gitcmds module."""
10 helper
.GitRepositoryTestCase
.setUp(self
)
11 self
.config
= gitcfg
.instance()
13 def test_string(self
):
14 """Test string values in get()."""
15 self
.shell('git config test.value test')
16 self
.assertEqual(self
.config
.get('test.value'), 'test')
19 """Test int values in get()."""
20 self
.shell('git config test.int 42')
21 self
.assertEqual(self
.config
.get('test.int'), 42)
24 """Test bool values in get()."""
25 self
.shell('git config test.bool true')
26 self
.assertEqual(self
.config
.get('test.bool'), True)
29 self
.shell('git config test.bool false')
30 self
.assertEqual(self
.config
.get('test.bool'), False)
33 self
.shell('git config test.bool yes')
34 self
.assertEqual(self
.config
.get('test.bool'), True)
37 self
.shell('git config test.bool false')
38 self
.assertEqual(self
.config
.get('test.bool'), False)
40 def test_bool_no_value(self
):
41 self
.shell('printf "[test]\n" >> .git/config')
42 self
.shell('printf "\tbool\n" >> .git/config')
43 self
.assertEqual(self
.config
.get('test.bool'), True)
45 def test_empty_value(self
):
46 self
.shell('printf "[test]\n" >> .git/config')
47 self
.shell('printf "\tvalue = \n" >> .git/config')
48 self
.assertEqual(self
.config
.get('test.value'), '')
50 def test_default(self
):
51 """Test default values in get()."""
52 self
.assertEqual(self
.config
.get('does.not.exist'), None)
53 self
.assertEqual(self
.config
.get('does.not.exist', default
=42), 42)
56 if __name__
== '__main__':