Skip to content

Commit

Permalink
Fix test definition of igetattr recursion and context_manager_inference
Browse files Browse the repository at this point in the history
Ref pylint-dev#663. This test did not actually check for regression of the issue
fixed in 55076ca (i.e. it also passed on c87bea1 before the fix was
applied). Additionally, it over-specified the behaviour it was
attempting to check: whether the value returned from the context manager
was Uninferable was not directly relevant to the test, so when this
value changed due to unrelated fixes in inference, this test failed.
  • Loading branch information
nelfin committed May 2, 2021
1 parent 8ec2b47 commit 427d422
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions tests/unittest_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -5312,26 +5312,20 @@ class Cls:
def test_prevent_recursion_error_in_igetattr_and_context_manager_inference():
code = """
class DummyContext(object):
def method(self, msg): # pylint: disable=C0103
pass
def __enter__(self):
pass
return self
def __exit__(self, ex_type, ex_value, ex_tb):
return True
class CallMeMaybe(object):
def __call__(self):
while False:
with DummyContext() as con:
f_method = con.method
break
if False:
with DummyContext() as con:
pass
with DummyContext() as con:
con #@
f_method = con.method
with DummyContext() as con:
con.__enter__ #@
"""
node = extract_node(code)
assert next(node.infer()) is util.Uninferable
next(node.infer()) # should not raise StopIteration/RuntimeError


def test_infer_context_manager_with_unknown_args():
Expand Down

0 comments on commit 427d422

Please sign in to comment.