|
| 1 | +import re |
1 | 2 | import os |
2 | 3 | import sys |
3 | 4 | from pathlib import Path |
|
10 | 11 | import pytest |
11 | 12 | from ..utils import ( |
12 | 13 | _can_use_fixture, |
| 14 | + _is_in_describe_section_when_enabled, |
13 | 15 | _is_pytest_mark, |
14 | 16 | _is_pytest_mark_usefixtures, |
15 | 17 | _is_pytest_fixture, |
@@ -72,6 +74,7 @@ class FixtureChecker(BasePytestChecker): |
72 | 74 | _invoked_with_func_args = set() |
73 | 75 | _invoked_with_usefixtures = set() |
74 | 76 | _original_add_message = callable |
| 77 | + enable_plugin = True |
75 | 78 |
|
76 | 79 | def open(self): |
77 | 80 | # patch VariablesChecker.add_message |
@@ -217,6 +220,11 @@ def patch_add_message(self, msgid, line=None, node=None, args=None, |
217 | 220 | ''' |
218 | 221 | - intercept and discard unwanted warning messages |
219 | 222 | ''' |
| 223 | + if not FixtureChecker.enable_plugin: |
| 224 | + FixtureChecker._original_add_message( |
| 225 | + self, msgid, line, node, args, confidence, col_offset |
| 226 | + ) |
| 227 | + return |
220 | 228 | # check W0611 unused-import |
221 | 229 | if msgid == 'unused-import': |
222 | 230 | # actual attribute name is not passed as arg so...dirty hack |
@@ -265,6 +273,12 @@ def patch_add_message(self, msgid, line=None, node=None, args=None, |
265 | 273 | node.name in FixtureChecker._pytest_fixtures: |
266 | 274 | return |
267 | 275 |
|
| 276 | + # check W0612 unused-variable |
| 277 | + if msgid == 'unused-variable' and \ |
| 278 | + _is_in_describe_section_when_enabled(node): |
| 279 | + return |
| 280 | + |
| 281 | + |
268 | 282 | if int(pylint.__version__.split('.')[0]) >= 2: |
269 | 283 | FixtureChecker._original_add_message( |
270 | 284 | self, msgid, line, node, args, confidence, col_offset) |
|
0 commit comments