parent
62381125e7
commit
3ddbc7fb2a
|
@ -1 +1,2 @@
|
||||||
Fix ``self`` reference in function scoped fixtures that are in a plugin class
|
Fixed ``self`` reference in function-scoped fixtures defined plugin classes: previously ``self``
|
||||||
|
would be a reference to a *test* class, not the *plugin* class.
|
||||||
|
|
|
@ -897,6 +897,8 @@ def resolve_fixture_function(fixturedef, request):
|
||||||
# request.instance so that code working with "fixturedef" behaves
|
# request.instance so that code working with "fixturedef" behaves
|
||||||
# as expected.
|
# as expected.
|
||||||
if request.instance is not None:
|
if request.instance is not None:
|
||||||
|
# handle the case where fixture is defined not in a test class, but some other class
|
||||||
|
# (for example a plugin class with a fixture), see #2270
|
||||||
if hasattr(fixturefunc, "__self__") and not isinstance(
|
if hasattr(fixturefunc, "__self__") and not isinstance(
|
||||||
request.instance, fixturefunc.__self__.__class__
|
request.instance, fixturefunc.__self__.__class__
|
||||||
):
|
):
|
||||||
|
|
|
@ -3946,6 +3946,9 @@ class TestScopeOrdering:
|
||||||
reprec.assertoutcome(passed=2)
|
reprec.assertoutcome(passed=2)
|
||||||
|
|
||||||
def test_class_fixture_self_instance(self, testdir):
|
def test_class_fixture_self_instance(self, testdir):
|
||||||
|
"""Check that plugin classes which implement fixtures receive the plugin instance
|
||||||
|
as self (see #2270).
|
||||||
|
"""
|
||||||
testdir.makeconftest(
|
testdir.makeconftest(
|
||||||
"""
|
"""
|
||||||
import pytest
|
import pytest
|
||||||
|
|
Loading…
Reference in New Issue