Skip to content

Commit

Permalink
✅ Cover set/dict comprehension
Browse files Browse the repository at this point in the history
  • Loading branch information
valentingol committed Jan 8, 2024
1 parent ea7d50b commit f3a9377
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/unit/processing/test_ast_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ def test_ast_parser() -> None:
result = _process_node(node=tree.body, flat_dict=flat_dict)
check.equal(result, (0.2, 0.2))

expr = "sum([1 for _ in range(2)])"
expr = "sum([1 for _ in range(2)]), {i for i in range(3)}, {i: 0 for i in range(3)}"
tree = ast.parse(expr, mode="eval")
result = _process_node(node=tree.body, flat_dict=flat_dict)
check.equal(result, 2)
check.equal(result, (2, {0, 1, 2}, {0: 0, 1: 0, 2: 0}))

flat_dict = {"elems": [(1, 2), (3, 4), (5, 6)], "val": 2}
expr = "{'list': [i+2*j for i, j in elems if i > val]}, val"
expr = "{'list': [i+2*j for i, j in elems if i > val]}, {val}"
tree = ast.parse(expr, mode="eval")
result = _process_node(node=tree.body, flat_dict=flat_dict)
check.equal(result, ({"list": [11, 17]}, 2))
check.equal(result, ({"list": [11, 17]}, {2}))

flat_dict = {"a": {"b": 1}}
expr = "list(a.keys())"
Expand Down

0 comments on commit f3a9377

Please sign in to comment.