fixtures: use isinstance in get_scope_package

No reason for the exact type equality.
This commit is contained in:
Ran Benita 2023-05-14 23:09:16 +03:00
parent 1716d3c9bf
commit 5d53447a73
1 changed files with 2 additions and 3 deletions

View File

@ -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: