Skip to content

Commit

Permalink
Add test asserting that get_values works by itself
Browse files Browse the repository at this point in the history
As described in #1534, this test will fail in main with a KeyError
about a missing section name even though the named sections do exist
within the config file.

This test will pass in the branch associated with #1535. This test
should keep the improved behavior healthy as the code evolves by
preventing future developers from removing the eager loading of
sections within get_values().
  • Loading branch information
Codym48 committed Feb 16, 2023
1 parent cfc613a commit fc843d3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,17 @@ def test_empty_config_value(self):
with self.assertRaises(cp.NoOptionError):
cr.get_value("color", "ui")

def test_get_values_works_without_requiring_any_other_calls_first(self):
file_obj = self._to_memcache(fixture_path("git_config_multiple"))
cr = GitConfigParser(file_obj, read_only=True)
self.assertEqual(cr.get_values("section0", "option0"), ["value0"])
file_obj.seek(0)
cr = GitConfigParser(file_obj, read_only=True)
self.assertEqual(cr.get_values("section1", "option1"), ["value1a", "value1b"])
file_obj.seek(0)
cr = GitConfigParser(file_obj, read_only=True)
self.assertEqual(cr.get_values("section1", "other_option1"), ["other_value1"])

def test_multiple_values(self):
file_obj = self._to_memcache(fixture_path("git_config_multiple"))
with GitConfigParser(file_obj, read_only=False) as cw:
Expand Down

0 comments on commit fc843d3

Please sign in to comment.