Skip to content

Commit

Permalink
New test for builtin base name detection
Browse files Browse the repository at this point in the history
  • Loading branch information
andrecsilva committed Jan 11, 2024
1 parent 10a8344 commit a69a7ff
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tests/test_nameresolution_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,26 @@ def transform_module_impl(self, tree: cst.Module) -> cst.Module:
tree = cst.parse_module(input_code)
TestCodemod(CodemodContext()).transform_module(tree)

def test_get_base_name_no_import(self):
def test_get_base_name_no_assignment(self):
class TestCodemod(Codemod, NameResolutionMixin):
def transform_module_impl(self, tree: cst.Module) -> cst.Module:
stmt = cst.ensure_type(tree.body[-1], cst.SimpleStatementLine)
expr = cst.ensure_type(stmt.body[0], cst.Expr)
node = expr.value

maybe_name = self.find_base_name(node.func)
assert maybe_name == "foo"
return tree

input_code = dedent(
"""\
foo('hello world')
"""
)
tree = cst.parse_module(input_code)
TestCodemod(CodemodContext()).transform_module(tree)

def test_get_base_name_built_in(self):
class TestCodemod(Codemod, NameResolutionMixin):
def transform_module_impl(self, tree: cst.Module) -> cst.Module:
stmt = cst.ensure_type(tree.body[-1], cst.SimpleStatementLine)
Expand Down

0 comments on commit a69a7ff

Please sign in to comment.