Skip to content

Commit 3d048ca

Browse files
committed
Fix finding all functions in comparison
1 parent 5d92664 commit 3d048ca

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

pythonwhat/parsing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ def visit_AugAssign(self, node):
297297
self.visit(node.value)
298298

299299
def visit_Compare(self, node):
300+
self.visit(node.left)
300301
self.visit_each(node.comparators)
301302

302303
def visit_UnaryOp(self, node):

tests/test_check_function.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,3 +507,17 @@ def test_function_call_in_return():
507507
sct = "Ex().check_function_def('my_func').check_body().check_function('my_func_in_return', signature=False)"
508508
res = helper.run({"DC_CODE": code, "DC_SOLUTION": code, "DC_SCT": sct})
509509
assert res["correct"]
510+
511+
512+
@pytest.mark.parametrize(
513+
"code",
514+
[
515+
"0 < len([])",
516+
"len([]) < 3",
517+
"0 < len([]) < 3",
518+
],
519+
)
520+
def test_function_call_in_comparison(code):
521+
sct = "Ex().check_function('len')"
522+
res = helper.run({"DC_CODE": code, "DC_SOLUTION": code, "DC_SCT": sct})
523+
assert res["correct"]

0 commit comments

Comments
 (0)