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

Commit 2aed435

Browse files
committed
support @pytest.yield_fixture
1 parent 3201f96 commit 2aed435

File tree

7 files changed

+44
-1
lines changed

7 files changed

+44
-1
lines changed

pylint_pytest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def _is_pytest_fixture(decorator):
3333
# expecting @pytest.fixture(scope=...)
3434
attr = decorator.func
3535

36-
if attr and attr.attrname == 'fixture' and attr.expr.name == 'pytest':
36+
if attr and attr.attrname in ('fixture', 'yield_fixture') \
37+
and attr.expr.name == 'pytest':
3738
return True
3839
except AttributeError:
3940
pass
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import pytest
2+
from conftest import conftest_fixture_attr
3+
4+
5+
@pytest.yield_fixture
6+
def caller_yield_fixture(conftest_fixture_attr):
7+
assert conftest_fixture_attr
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import pytest
2+
from conftest import conftest_fixture_attr
3+
4+
5+
@pytest.yield_fixture
6+
def caller_yield_fixture(conftest_fixture_attr):
7+
assert True
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import pytest
2+
from conftest import conftest_fixture_attr
3+
4+
5+
@pytest.yield_fixture
6+
def caller_yield_fixture(conftest_fixture_attr):
7+
assert conftest_fixture_attr

tests/test_redefined_outer_name.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ def test_smoke(self, enable_plugin):
1212
msg_count=0 if enable_plugin else 1,
1313
)
1414

15+
@pytest.mark.parametrize('enable_plugin', [True, False])
16+
def test_caller_yield_fixture(self, enable_plugin):
17+
self.run_test(
18+
enable_plugin=enable_plugin,
19+
msg_count=0 if enable_plugin else 1,
20+
)
21+
1522
@pytest.mark.parametrize('enable_plugin', [True, False])
1623
def test_caller_not_a_test_func(self, enable_plugin):
1724
self.run_test(

tests/test_unused_argument.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ def test_smoke(self, enable_plugin):
1212
msg_count=0 if enable_plugin else 2,
1313
)
1414

15+
@pytest.mark.parametrize('enable_plugin', [True, False])
16+
def test_caller_yield_fixture(self, enable_plugin):
17+
self.run_test(
18+
enable_plugin=enable_plugin,
19+
msg_count=0 if enable_plugin else 1,
20+
)
21+
1522
@pytest.mark.parametrize('enable_plugin', [True, False])
1623
def test_caller_not_a_test_func(self, enable_plugin):
1724
self.run_test(

tests/test_unused_import.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ def test_smoke(self, enable_plugin):
1212
msg_count=0 if enable_plugin else 1,
1313
)
1414

15+
@pytest.mark.parametrize('enable_plugin', [True, False])
16+
def test_caller_yield_fixture(self, enable_plugin):
17+
self.run_test(
18+
enable_plugin=enable_plugin,
19+
msg_count=0 if enable_plugin else 1,
20+
)
21+
1522
@pytest.mark.parametrize('enable_plugin', [True, False])
1623
def test_same_name_arg(self, enable_plugin):
1724
'''an unused import (not a fixture) just happened to have the same

0 commit comments

Comments
 (0)