From f17fe442a27a217bec0c8770cd1ef49b49cd3cb4 Mon Sep 17 00:00:00 2001 From: Rasmus Wriedt Larsen Date: Thu, 20 May 2021 14:52:10 +0200 Subject: [PATCH] Python: Expand test of py/use-of-input --- .../2/query-tests/Expressions/UseofApply.expected | 2 +- .../2/query-tests/Expressions/expressions_test.py | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/python/ql/test/2/query-tests/Expressions/UseofApply.expected b/python/ql/test/2/query-tests/Expressions/UseofApply.expected index aac8fbcda880..0c5e28c94940 100644 --- a/python/ql/test/2/query-tests/Expressions/UseofApply.expected +++ b/python/ql/test/2/query-tests/Expressions/UseofApply.expected @@ -1,2 +1,2 @@ | UseofApply.py:19:3:19:17 | ControlFlowNode for apply() | Call to the obsolete builtin function 'apply'. | -| expressions_test.py:3:5:3:21 | ControlFlowNode for apply() | Call to the obsolete builtin function 'apply'. | +| expressions_test.py:2:5:2:21 | ControlFlowNode for apply() | Call to the obsolete builtin function 'apply'. | diff --git a/python/ql/test/2/query-tests/Expressions/expressions_test.py b/python/ql/test/2/query-tests/Expressions/expressions_test.py index 943bcea98a85..c31681e35353 100644 --- a/python/ql/test/2/query-tests/Expressions/expressions_test.py +++ b/python/ql/test/2/query-tests/Expressions/expressions_test.py @@ -1,7 +1,18 @@ - def use_of_apply(func, args): apply(func, args) + def use_of_input(): - return input() + return input() # NOT OK + + +def not_use_of_input(): + input = raw_input + return input() # OK + +if __name__ == "__main__": + # if you enter 4+4 each time, you'll see that results are: 8, '4+4', 8 + print("result:", use_of_input()) + print("result:", not_use_of_input()) + print("result:", use_of_input())