We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fcebde9 commit 6c636bfCopy full SHA for 6c636bf
1 file changed
tests/test_ast_function_source_utils.py
@@ -21,3 +21,23 @@ def test_collect_function_sources_reads_sync_and_async_functions():
21
assert "post_model_response_data_async(" in function_sources[
22
"post_model_request_async"
23
]
24
+
25
26
+def test_collect_function_sources_returns_top_level_functions_only(tmp_path):
27
+ module_path = tmp_path / "sample_module.py"
28
+ module_path.write_text(
29
+ "def top_level():\n"
30
+ " return 'ok'\n\n"
31
+ "class Example:\n"
32
+ " def method(self):\n"
33
+ " return 'method'\n\n"
34
+ "def wrapper():\n"
35
+ " def nested():\n"
36
+ " return 'nested'\n"
37
+ " return nested()\n",
38
+ encoding="utf-8",
39
+ )
40
41
+ function_sources = collect_function_sources(str(module_path))
42
43
+ assert sorted(function_sources.keys()) == ["top_level", "wrapper"]
0 commit comments