Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e5a2db5

Browse files
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. - Quoted case, where extra whitespace is next to but outside of the quotes. The case where the whitespace is at the edges of the quoted value and *inside* the quotes, and thus part of the value, is already covered in #2036. (That is merely renamed here, to distinguish it.)
1 parent 2e0d835 commit e5a2db5

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
File renamed without changes.
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"), "cveal05@gmail.com")
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)

AltStyle によって変換されたページ (->オリジナル) /