python-benedict/tests/github/test_issue_0016.py

43 lines
1.1 KiB
Python
Raw Normal View History

2020-09-22 12:10:59 +00:00
import unittest
from benedict import benedict
2020-09-22 12:10:59 +00:00
class github_issue_0016_test_case(unittest.TestCase):
2022-02-13 10:35:43 +00:00
"""
This class describes a github issue 0016 test case.
"""
2020-09-22 12:10:59 +00:00
def test_github_issue_0016(self):
"""
https://github.com/fabiocaccamo/python-benedict/issues/16
"""
d = {
2022-02-13 10:35:43 +00:00
"components": [
2020-09-22 12:10:59 +00:00
{
2022-02-13 10:35:43 +00:00
"name": "comp1",
"value": "value1",
"subcomponent": {
"name": "subcomp1",
2020-09-22 12:10:59 +00:00
},
},
{
2022-02-13 10:35:43 +00:00
"name": "comp2",
"value": "value2",
"subcomponent": {
"name": "subcomp2",
2020-09-22 12:10:59 +00:00
},
},
{
2022-02-13 10:35:43 +00:00
"name": "comp3",
"value": "value3",
"subcomponent": {
"name": "subcomp3",
2020-09-22 12:10:59 +00:00
},
},
],
}
b = benedict(d)
2022-02-13 10:35:43 +00:00
v = b.match("components[*].subcomponent.name")
self.assertEqual(v, ["subcomp1", "subcomp2", "subcomp3"])