Skip to content

Commit

Permalink
more inference tests (#1908)
Browse files Browse the repository at this point in the history
## Changes
more tests

### Linked issues
Progresses #1901 

### Functionality 
None

### Tests
- [x] added unit tests

Co-authored-by: Eric Vergnaud <[email protected]>
  • Loading branch information
ericvergnaud and ericvergnaud authored Jun 14, 2024
1 parent b80a7e1 commit deae2df
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/unit/source_code/linters/test_python_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ def test_infers_fstring_value():
assert strings == ["Hello abc!"]


def test_infers_string_format_value():
source = """
value = "abc"
fstring = "Hello {0}!".format(value)
"""
tree = Tree.parse(source)
nodes = tree.locate(Assign, [])
tree = Tree(nodes[1].value) # value of fstring = ...
values = list(tree.infer_values())
assert all(value.is_inferred() for value in values)
strings = list(value.as_string() for value in values)
assert strings == ["Hello abc!"]


def test_infers_fstring_values():
source = """
values_1 = ["abc", "def"]
Expand Down

0 comments on commit deae2df

Please sign in to comment.