1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00

allow duplicate keys

This commit is contained in:
Kelly Brazil
2022-04-04 11:38:52 -07:00
parent d5e9074f1c
commit a2ef9c429e
4 changed files with 38 additions and 8 deletions

View File

@ -41,6 +41,18 @@ class MyTests(unittest.TestCase):
"""
self.assertEqual(jc.parsers.ini.parse(self.generic_ini_iptelserver, quiet=True), self.generic_ini_iptelserver_json)
def test_ini_duplicate_keys(self):
"""
Test input that contains duplicate keys. Only the last value should be used.
"""
data = '''
duplicate_key: value1
another_key = foo
duplicate_key = value2
'''
expected = {'duplicate_key': 'value2', 'another_key': 'foo'}
self.assertEqual(jc.parsers.ini.parse(data, quiet=True), expected)
if __name__ == '__main__':
unittest.main()