python-benedict/tests/github/test_issue_0027.py

30 lines
781 B
Python
Raw Normal View History

2021-10-04 09:40:25 +00:00
import unittest
from benedict import benedict
2021-10-04 09:40:25 +00:00
class github_issue_0027_test_case(unittest.TestCase):
"""
2022-02-13 10:35:43 +00:00
This class describes a github issue 0027 test case.
2021-10-04 09:40:25 +00:00
https://github.com/fabiocaccamo/python-benedict/issues/27
To run this specific test:
- Run python -m unittest tests.github.test_issue_0027
"""
def test_append_to_list_with_empty_index(self):
2022-02-13 10:35:43 +00:00
d = benedict(
{
"results": [
{
"locations": ["Torino", "Milano", "Napoli"],
},
]
}
)
d["results[0].locations"].append("Roma")
self.assertEqual(
d["results[0].locations"], ["Torino", "Milano", "Napoli", "Roma"]
)
2021-10-04 09:40:25 +00:00
return d