@@ -291,9 +291,7 @@ def _add_kwargs(
291
291
return ret
292
292
293
293
294
- def _perhaps_rebind_fixture_func (
295
- func : _T , instance : Optional [Any ], unittest : bool
296
- ) -> _T :
294
+ def _perhaps_rebind_fixture_func (func : _T , instance : Optional [Any ]) -> _T :
297
295
if instance is not None :
298
296
# The fixture needs to be bound to the actual request.instance
299
297
# so it is bound to the same object as the test method.
@@ -302,10 +300,9 @@ def _perhaps_rebind_fixture_func(
302
300
unbound , cls = func .__func__ , type (func .__self__ ) # type: ignore
303
301
except AttributeError :
304
302
pass
305
- # If unittest is true, the fixture is bound unconditionally.
306
- # otherwise, only if the fixture was bound before to an instance of
303
+ # Only if the fixture was bound before to an instance of
307
304
# the same type.
308
- if unittest or ( cls is not None and isinstance (instance , cls ) ):
305
+ if cls is not None and isinstance (instance , cls ):
309
306
func = unbound .__get__ (instance ) # type: ignore
310
307
return func
311
308
@@ -315,7 +312,7 @@ def _wrap_asyncgen_fixture(fixturedef: FixtureDef) -> None:
315
312
316
313
@functools .wraps (fixture )
317
314
def _asyncgen_fixture_wrapper (request : FixtureRequest , ** kwargs : Any ):
318
- func = _perhaps_rebind_fixture_func (fixture , request .instance , False )
315
+ func = _perhaps_rebind_fixture_func (fixture , request .instance )
319
316
event_loop_fixture_id = _get_event_loop_fixture_id_for_async_fixture (
320
317
request , func
321
318
)
@@ -354,7 +351,7 @@ def _wrap_async_fixture(fixturedef: FixtureDef) -> None:
354
351
355
352
@functools .wraps (fixture )
356
353
def _async_fixture_wrapper (request : FixtureRequest , ** kwargs : Any ):
357
- func = _perhaps_rebind_fixture_func (fixture , request .instance , False )
354
+ func = _perhaps_rebind_fixture_func (fixture , request .instance )
358
355
event_loop_fixture_id = _get_event_loop_fixture_id_for_async_fixture (
359
356
request , func
360
357
)
0 commit comments