Collapse all parent nested package fixtures when pointing to a sub-node.

Example:
Given this hierarchy: p1.s1.s2.s3
I want to run pytest p1/s1/s2/s3/foo.py

If there are any package fixtures defined at p1..s2 levels, they should also be executed.
This commit is contained in:
turturica 2018-04-20 17:15:09 -07:00
parent 69031d0033
commit dc90c9108f
1 changed files with 4 additions and 3 deletions

View File

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