Skip to content

Commit fcebde9

Browse files
Cover AST import-helper alias and import-style edge cases
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 64ba087 commit fcebde9

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/test_ast_import_utils.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,21 @@ def test_imports_collect_function_sources_ignores_non_matching_imports():
2121
)
2222

2323
assert imports_collect_function_sources(module_text) is False
24+
25+
26+
def test_imports_collect_function_sources_supports_aliased_import():
27+
module_text = (
28+
"from tests.ast_function_source_utils import collect_function_sources as cfs\n"
29+
"cfs('tests/test_model_request_wrapper_internal_reuse.py')\n"
30+
)
31+
32+
assert imports_collect_function_sources(module_text) is True
33+
34+
35+
def test_imports_collect_function_sources_ignores_non_from_imports():
36+
module_text = (
37+
"import tests.ast_function_source_utils as source_utils\n"
38+
"source_utils.collect_function_sources('tests/test_web_request_wrapper_internal_reuse.py')\n"
39+
)
40+
41+
assert imports_collect_function_sources(module_text) is False

0 commit comments

Comments
 (0)