File tree Expand file tree Collapse file tree 2 files changed +49
-4
lines changed Expand file tree Collapse file tree 2 files changed +49
-4
lines changed Original file line number Diff line number Diff line change @@ -754,8 +754,8 @@ def finish(self):
754754 func = self ._finalizer .pop ()
755755 func ()
756756 finally :
757- ihook = self ._fixturemanager .session .ihook
758- ihook .pytest_fixture_post_finalizer (fixturedef = self )
757+ hook = self ._fixturemanager .session .config . hook
758+ hook .pytest_fixture_post_finalizer (fixturedef = self )
759759 # even if finalization fails, we invalidate
760760 # the cached fixture value
761761 if hasattr (self , "cached_result" ):
@@ -783,8 +783,8 @@ def execute(self, request):
783783 self .finish ()
784784 assert not hasattr (self , "cached_result" )
785785
786- ihook = self ._fixturemanager .session .ihook
787- return ihook .pytest_fixture_setup (fixturedef = self , request = request )
786+ hook = self ._fixturemanager .session .config . hook
787+ return hook .pytest_fixture_setup (fixturedef = self , request = request )
788788
789789 def __repr__ (self ):
790790 return ("<FixtureDef name=%r scope=%r baseid=%r >" %
Original file line number Diff line number Diff line change @@ -2984,4 +2984,49 @@ def test_foo(request):
29842984 """ .format (fixfile .strpath , testfile .basename ))
29852985
29862986
2987+ def test_pytest_fixture_setup_hook (testdir ):
2988+ testdir .makeconftest ("""
2989+ import pytest
2990+
2991+ def pytest_fixture_setup():
2992+ print('pytest_fixture_setup hook called')
2993+ """ )
2994+ testdir .makepyfile ("""
2995+ import pytest
2996+
2997+ @pytest.fixture()
2998+ def some():
2999+ return 'some'
3000+
3001+ def test_func(some):
3002+ assert some == 'some'
3003+ """ )
3004+ result = testdir .runpytest ("-s" )
3005+ assert result .ret == 0
3006+ result .stdout .fnmatch_lines ([
3007+ "*pytest_fixture_setup hook called*" ,
3008+ ])
3009+
3010+
3011+ def test_pytest_fixture_post_finalizer_hook (testdir ):
3012+ testdir .makeconftest ("""
3013+ import pytest
29873014
3015+ def pytest_fixture_post_finalizer():
3016+ print('pytest_fixture_post_finalizer hook called')
3017+ """ )
3018+ testdir .makepyfile ("""
3019+ import pytest
3020+
3021+ @pytest.fixture()
3022+ def some():
3023+ return 'some'
3024+
3025+ def test_func(some):
3026+ assert some == 'some'
3027+ """ )
3028+ result = testdir .runpytest ("-s" )
3029+ assert result .ret == 0
3030+ result .stdout .fnmatch_lines ([
3031+ "*pytest_fixture_post_finalizer hook called*" ,
3032+ ])
You can’t perform that action at this time.
0 commit comments