summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCody Martin <codytylermartin@gmail.com>2023-02-15 22:07:56 -0700
committerCody Martin <codytylermartin@gmail.com>2023-02-15 22:07:56 -0700
commitfc843d31ddb817deb8e5e6732ebe67a5ee61db66 (patch)
treebc8cf85060fb9b5106c860cc7e2c2e517ecf4bc3
parentcfc613a866921dab9228d5c21587e62f30ec6a57 (diff)
downloadgitpython-fc843d31ddb817deb8e5e6732ebe67a5ee61db66.tar.gz
Add test asserting that get_values works by itself
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().
-rw-r--r--test/test_config.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/test_config.py b/test/test_config.py
index 8bb2aa30..b159ebe2 100644
--- a/test/test_config.py
+++ b/test/test_config.py
@@ -398,6 +398,17 @@ class TestBase(TestCase):
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: