diff --git a/_pytest/fixtures.py b/_pytest/fixtures.py index e4bb91514..e9d032f92 100644 --- a/_pytest/fixtures.py +++ b/_pytest/fixtures.py @@ -75,10 +75,11 @@ def get_scope_package(node, fixturedef): cls = node.Package current = node fixture_package_name = os.path.join(fixturedef.baseid, '__init__.py') - while current and type(current) is not cls or \ - fixture_package_name != current.nodeid: + while current and (type(current) is not cls or \ + fixture_package_name != current.nodeid): current = current.parent - assert current + if current is None: + return node.session return current