Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

Commit e2c3d28

Browse files
committed
fix crash on args/kwargs
1 parent 87b986b commit e2c3d28

File tree

5 files changed

+32
-4
lines changed

5 files changed

+32
-4
lines changed

pylint_pytest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,14 @@ def patched_add_message(self, msgid, line=None, node=None, args=None,
191191

192192
# check W0613 unused-argument
193193
if msgid == 'unused-argument' and \
194-
node.name in self._pytest_fixtures and \
195-
_can_use_fixture(node.parent.parent):
194+
_can_use_fixture(node.parent.parent) and \
195+
node.name in self._pytest_fixtures:
196196
return
197197

198198
# check W0621 redefined-outer-name
199199
if msgid == 'redefined-outer-name' and \
200-
node.name in self._pytest_fixtures and \
201-
_can_use_fixture(node.parent.parent):
200+
_can_use_fixture(node.parent.parent) and \
201+
node.name in self._pytest_fixtures:
202202
return
203203

204204
if int(pylint.__version__.split('.')[0]) >= 2:
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def args():
2+
pass
3+
4+
5+
def kwargs():
6+
pass
7+
8+
9+
def not_a_test_function(*args, **kwargs):
10+
# invalid test case...
11+
assert True
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def not_a_test_function(*args, **kwargs):
2+
# invalid test case...
3+
assert True

tests/test_redefined_outer_name.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,10 @@ def test_caller_not_a_test_func(self, enable_plugin):
1818
enable_plugin=enable_plugin,
1919
msg_count=1,
2020
)
21+
22+
@pytest.mark.parametrize('enable_plugin', [True, False])
23+
def test_args_and_kwargs(self, enable_plugin):
24+
self.run_test(
25+
enable_plugin=enable_plugin,
26+
msg_count=2,
27+
)

tests/test_unused_argument.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,10 @@ def test_caller_not_a_test_func(self, enable_plugin):
1818
enable_plugin=enable_plugin,
1919
msg_count=1,
2020
)
21+
22+
@pytest.mark.parametrize('enable_plugin', [True, False])
23+
def test_args_and_kwargs(self, enable_plugin):
24+
self.run_test(
25+
enable_plugin=enable_plugin,
26+
msg_count=2,
27+
)

0 commit comments

Comments
 (0)