We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 46a83c3 commit f9f17ecCopy full SHA for f9f17ec
tests/test_guardrail_ast_utils.py
@@ -0,0 +1,28 @@
1
+import ast
2
+
3
+from tests.guardrail_ast_utils import (
4
+ collect_attribute_call_lines,
5
+ collect_list_keys_call_lines,
6
+ collect_name_call_lines,
7
+)
8
9
10
+SAMPLE_MODULE = ast.parse(
11
+ """
12
+values = list(mapping.keys())
13
+result = helper()
14
+other = obj.method()
15
+"""
16
17
18
19
+def test_collect_name_call_lines_returns_named_calls():
20
+ assert collect_name_call_lines(SAMPLE_MODULE, "helper") == [3]
21
22
23
+def test_collect_attribute_call_lines_returns_attribute_calls():
24
+ assert collect_attribute_call_lines(SAMPLE_MODULE, "method") == [4]
25
26
27
+def test_collect_list_keys_call_lines_returns_list_key_calls():
28
+ assert collect_list_keys_call_lines(SAMPLE_MODULE) == [2]
0 commit comments