Skip to content

Commit dd23f11

Browse files
committed
Test ConfigParser with whitespace outside the value
In both the unquoted case, where extra whitespace is at the edges of what can be parsed as the value, and the unquoted case, where extra whitespace is next to but outside of the quotes.
1 parent 2e0d835 commit dd23f11

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[init]
2+
defaultBranch = trunk
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[init]
2+
defaultBranch = "trunk"

test/test_config.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ def test_complex_aliases(self):
398398
self._to_memcache(fixture_path(".gitconfig")).getvalue(),
399399
)
400400

401+
def test_config_with_extra_whitespace(self):
402+
cr = GitConfigParser(fixture_path("git_config_with_extra_whitespace"), read_only=True)
403+
self.assertEqual(cr.get("init", "defaultBranch"), "trunk")
404+
401405
def test_empty_config_value(self):
402406
cr = GitConfigParser(fixture_path("git_config_with_empty_value"), read_only=True)
403407

@@ -413,9 +417,13 @@ def test_config_with_quotes(self):
413417
self.assertEqual(cr.get("user", "email"), "[email protected]")
414418

415419
def test_config_with_quotes_with_literal_whitespace(self):
416-
cr = GitConfigParser(fixture_path("git_config_with_quotes_whitespace"), read_only=True)
420+
cr = GitConfigParser(fixture_path("git_config_with_quotes_whitespace_inside"), read_only=True)
417421
self.assertEqual(cr.get("core", "commentString"), "# ")
418422

423+
def test_config_with_quotes_with_whitespace_outside_value(self):
424+
cr = GitConfigParser(fixture_path("git_config_with_quotes_whitespace_outside"), read_only=True)
425+
self.assertEqual(cr.get("init", "defaultBranch"), "trunk")
426+
419427
def test_get_values_works_without_requiring_any_other_calls_first(self):
420428
file_obj = self._to_memcache(fixture_path("git_config_multiple"))
421429
cr = GitConfigParser(file_obj, read_only=True)

0 commit comments

Comments
 (0)