summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2023-01-31 22:11:02 +0100
committerGitHub <noreply@github.com>2023-01-31 22:11:02 +0100
commit56582d5eb123a476eea99c6c1fcb93409d790258 (patch)
treea3a5b4eadc3417fe4ede3a89023e147fba915e07 /tests
parentb644c1e834b491b465c5d61ead0373342029621a (diff)
downloadastroid-git-56582d5eb123a476eea99c6c1fcb93409d790258.tar.gz
Revert CallContext change since it caused a RecursionError regression (#2000) (#2001)
This reverts commit a0d219cb3403cda3338a14ce67a60954b4ff5cd7 (#1982). (cherry picked from commit 72f5afb8c3a15114f8033a51b390f845b49a209c) Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/unittest_brain.py9
-rw-r--r--tests/unittest_inference.py5
-rw-r--r--tests/unittest_inference_calls.py5
3 files changed, 12 insertions, 7 deletions
diff --git a/tests/unittest_brain.py b/tests/unittest_brain.py
index 30594c38..dd929bd0 100644
--- a/tests/unittest_brain.py
+++ b/tests/unittest_brain.py
@@ -2160,6 +2160,13 @@ class TypingBrain(unittest.TestCase):
assert inferred.value == 42
def test_typing_cast_multiple_inference_calls(self) -> None:
+ """Inference of an outer function should not store the result for cast.
+
+ https://github.com/PyCQA/pylint/issues/8074
+
+ Possible solution caused RecursionErrors with Python 3.8 and CPython + PyPy.
+ https://github.com/PyCQA/astroid/pull/1982
+ """
ast_nodes = builder.extract_node(
"""
from typing import TypeVar, cast
@@ -2177,7 +2184,7 @@ class TypingBrain(unittest.TestCase):
i1 = next(ast_nodes[1].infer())
assert isinstance(i1, nodes.Const)
- assert i1.value == "Hello"
+ assert i1.value == 2 # should be "Hello"!
@pytest.mark.skipif(
diff --git a/tests/unittest_inference.py b/tests/unittest_inference.py
index eda8b5f3..5aebd047 100644
--- a/tests/unittest_inference.py
+++ b/tests/unittest_inference.py
@@ -23,7 +23,7 @@ from astroid import helpers, nodes, objects, test_utils, util
from astroid.arguments import CallSite
from astroid.bases import BoundMethod, Instance, UnboundMethod, UnionType
from astroid.builder import AstroidBuilder, _extract_single_node, extract_node, parse
-from astroid.const import IS_PYPY, PY38_PLUS, PY39_PLUS, PY310_PLUS
+from astroid.const import PY38_PLUS, PY39_PLUS, PY310_PLUS
from astroid.context import InferenceContext
from astroid.exceptions import (
AstroidTypeError,
@@ -6934,9 +6934,6 @@ def test_imported_module_var_inferable3() -> None:
assert i_w_val.as_string() == "['w', 'v']"
-@pytest.mark.skipif(
- IS_PYPY, reason="Test run with coverage on PyPy sometimes raises a RecursionError"
-)
def test_recursion_on_inference_tip() -> None:
"""Regression test for recursion in inference tip.
diff --git a/tests/unittest_inference_calls.py b/tests/unittest_inference_calls.py
index 84a611d3..72afb989 100644
--- a/tests/unittest_inference_calls.py
+++ b/tests/unittest_inference_calls.py
@@ -146,6 +146,8 @@ def test_inner_call_with_const_argument() -> None:
def test_inner_call_with_dynamic_argument() -> None:
"""Test function where return value is the result of a separate function call,
with a dynamic value passed to the inner function.
+
+ Currently, this is Uninferable.
"""
node = builder.extract_node(
"""
@@ -161,8 +163,7 @@ def test_inner_call_with_dynamic_argument() -> None:
assert isinstance(node, nodes.NodeNG)
inferred = node.inferred()
assert len(inferred) == 1
- assert isinstance(inferred[0], nodes.Const)
- assert inferred[0].value == 3
+ assert inferred[0] is Uninferable
def test_method_const_instance_attr() -> None: