From 5d53447a73940fd6ff2bc53dd58ac61b861d34e8 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 14 May 2023 23:09:16 +0300 Subject: [PATCH] fixtures: use isinstance in get_scope_package No reason for the exact type equality. --- src/_pytest/fixtures.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 85039034e..0462504ef 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -117,13 +117,12 @@ def get_scope_package( node: nodes.Item, fixturedef: "FixtureDef[object]", ) -> Optional[Union[nodes.Item, nodes.Collector]]: - import pytest + from _pytest.python import Package - cls = pytest.Package current: Optional[Union[nodes.Item, nodes.Collector]] = node fixture_package_name = "{}/{}".format(fixturedef.baseid, "__init__.py") while current and ( - type(current) is not cls or fixture_package_name != current.nodeid + not isinstance(current, Package) or fixture_package_name != current.nodeid ): current = current.parent # type: ignore[assignment] if current is None: