Skip to content

Commit fc843d3

Browse files
committed
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().
1 parent cfc613a commit fc843d3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/test_config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,17 @@ def test_empty_config_value(self):
398398
with self.assertRaises(cp.NoOptionError):
399399
cr.get_value("color", "ui")
400400

401+
def test_get_values_works_without_requiring_any_other_calls_first(self):
402+
file_obj = self._to_memcache(fixture_path("git_config_multiple"))
403+
cr = GitConfigParser(file_obj, read_only=True)
404+
self.assertEqual(cr.get_values("section0", "option0"), ["value0"])
405+
file_obj.seek(0)
406+
cr = GitConfigParser(file_obj, read_only=True)
407+
self.assertEqual(cr.get_values("section1", "option1"), ["value1a", "value1b"])
408+
file_obj.seek(0)
409+
cr = GitConfigParser(file_obj, read_only=True)
410+
self.assertEqual(cr.get_values("section1", "other_option1"), ["other_value1"])
411+
401412
def test_multiple_values(self):
402413
file_obj = self._to_memcache(fixture_path("git_config_multiple"))
403414
with GitConfigParser(file_obj, read_only=False) as cw:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy