summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJacob Walls <jacobtylerwalls@gmail.com>2023-03-03 08:46:15 -0500
committerGitHub <noreply@github.com>2023-03-03 08:46:15 -0500
commit925910a8f2c9005a02597cfa2b830bf5a5eef9d8 (patch)
tree1f65ca8807c45b72f583b3ba1a0313fa27584607 /tests
parent47430fd4045031bd2920611840948dfd9dfdafae (diff)
downloadastroid-git-925910a8f2c9005a02597cfa2b830bf5a5eef9d8.tar.gz
Infer returns from match cases (#2042)
Diffstat (limited to 'tests')
-rw-r--r--tests/test_nodes.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test_nodes.py b/tests/test_nodes.py
index 83c1a41d..06334346 100644
--- a/tests/test_nodes.py
+++ b/tests/test_nodes.py
@@ -1947,3 +1947,22 @@ class TestPatternMatching:
case1.pattern.cls,
*case1.pattern.kwd_patterns,
]
+
+ @staticmethod
+ def test_return_from_match():
+ code = textwrap.dedent(
+ """
+ def return_from_match(x):
+ match x:
+ case 10:
+ return 10
+ case _:
+ return -1
+
+ return_from_match(10) #@
+ """
+ ).strip()
+ node = builder.extract_node(code)
+ inferred = node.inferred()
+ assert len(inferred) == 2
+ assert [inf.value for inf in inferred] == [10, -1]