Skip to content

Commit

Permalink
Add test for conditionally defined functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Feb 25, 2024
1 parent 5a86f41 commit 38bb9c0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -4352,6 +4352,22 @@ def foo(self):
assert len(inferred) == 1
assert isinstance(inferred[0], Generator)

def test_infer_function_under_if(self) -> None:
node = extract_node(
"""
if 1 in [1]:
def func():
return 42
else:
def func():
return False
func() #@
"""
)
inferred = list(node.inferred())
assert [const.value for const in inferred] == [42, False]

def test_delayed_attributes_without_slots(self) -> None:
ast_node = extract_node(
"""
Expand Down

0 comments on commit 38bb9c0

Please sign in to comment.