Skip to content

Commit a0be95c

Browse files
Cover generic AST import helper alias and non-from edge cases
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent da6304b commit a0be95c

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

tests/test_ast_import_utils.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,38 @@ def test_imports_symbol_from_module_ignores_unrelated_symbols():
6060
)
6161

6262

63+
def test_imports_symbol_from_module_supports_aliased_symbol_import():
64+
module_text = (
65+
"from tests.ast_import_utils import imports_collect_function_sources as helper\n"
66+
"helper('dummy')\n"
67+
)
68+
69+
assert (
70+
imports_symbol_from_module(
71+
module_text,
72+
module="tests.ast_import_utils",
73+
symbol="imports_collect_function_sources",
74+
)
75+
is True
76+
)
77+
78+
79+
def test_imports_symbol_from_module_ignores_non_from_import():
80+
module_text = (
81+
"import tests.ast_import_utils as import_utils\n"
82+
"import_utils.imports_collect_function_sources('dummy')\n"
83+
)
84+
85+
assert (
86+
imports_symbol_from_module(
87+
module_text,
88+
module="tests.ast_import_utils",
89+
symbol="imports_collect_function_sources",
90+
)
91+
is False
92+
)
93+
94+
6395
def test_imports_collect_function_sources_supports_aliased_import():
6496
module_text = (
6597
"from tests.ast_function_source_utils import collect_function_sources as cfs\n"

0 commit comments

Comments
 (0)