Skip to content

Commit

Permalink
Now that we support IfExp inference, address a test
Browse files Browse the repository at this point in the history
  • Loading branch information
PCManticore committed Jun 1, 2019
1 parent 8f8587e commit d14440f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pylint/test/extensions/data/redefined.py
Expand Up @@ -18,7 +18,7 @@ def __init__(self):
self.a_str = "hello"
a_str = False
(a_str, b_str) = (1, 2) # no support for inference on tuple assignment
a_str = 2.0 if self.var else 1.0 # no support for inference on ifexpr
a_str = 2.0 if self.var else 1.0

def _getter(self):
return self.a_str
Expand Down
28 changes: 14 additions & 14 deletions pylint/test/extensions/test_redefined.py
Expand Up @@ -15,15 +15,16 @@
from pylint.lint import fix_import_path

EXPECTED = [
'Redefinition of self.var1 type from int to float',
'Redefinition of var type from int to str',
'Redefinition of myint type from int to bool',
'Redefinition of _OK type from bool to str',
'Redefinition of instance type from redefined.MyClass to bool',
'Redefinition of SOME_FLOAT type from float to int',
'Redefinition of var3 type from str to int',
'Redefinition of var type from bool to int',
'Redefinition of var4 type from float to str',
"Redefinition of self.var1 type from int to float",
"Redefinition of a_str type from bool to float",
"Redefinition of var type from int to str",
"Redefinition of myint type from int to bool",
"Redefinition of _OK type from bool to str",
"Redefinition of instance type from redefined.MyClass to bool",
"Redefinition of SOME_FLOAT type from float to int",
"Redefinition of var3 type from str to int",
"Redefinition of var type from bool to int",
"Redefinition of var4 type from float to str",
]


Expand All @@ -34,16 +35,15 @@ def checker(checker):

@pytest.fixture(scope="module")
def disable(disable):
return ['I']
return ["I"]


def test_types_redefined(linter):
elif_test = osp.join(osp.dirname(osp.abspath(__file__)), 'data',
'redefined.py')
elif_test = osp.join(osp.dirname(osp.abspath(__file__)), "data", "redefined.py")
with fix_import_path([elif_test]):
linter.check([elif_test])
msgs = sorted(linter.reporter.messages, key=lambda item: item.line)
assert len(msgs) == 9
assert len(msgs) == 10
for msg, expected in zip(msgs, EXPECTED):
assert msg.symbol == 'redefined-variable-type'
assert msg.symbol == "redefined-variable-type"
assert msg.msg == expected

0 comments on commit d14440f

Please sign in to comment.