Skip to content

Make SubRequest.addfinalizer an explicit method #2914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion _pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,6 @@ def __init__(self, request, scope, param, param_index, fixturedef):
self.param_index = param_index
self.scope = scope
self._fixturedef = fixturedef
self.addfinalizer = fixturedef.addfinalizer
self._pyfuncitem = request._pyfuncitem
self._fixture_values = request._fixture_values
self._fixture_defs = request._fixture_defs
Expand All @@ -586,6 +585,9 @@ def __init__(self, request, scope, param, param_index, fixturedef):
def __repr__(self):
return "<SubRequest %r for %r>" % (self.fixturename, self._pyfuncitem)

def addfinalizer(self, finalizer):
self._fixturedef.addfinalizer(finalizer)


class ScopeMismatchError(Exception):
""" A fixture function tries to use a different fixture function which
Expand Down