commit
939a792c41
|
@ -505,8 +505,9 @@ class Session(nodes.FSCollector):
|
||||||
root = self._node_cache[pkginit]
|
root = self._node_cache[pkginit]
|
||||||
else:
|
else:
|
||||||
col = root._collectfile(pkginit)
|
col = root._collectfile(pkginit)
|
||||||
if col and isinstance(col, Package):
|
if col:
|
||||||
root = col[0]
|
if isinstance(col[0], Package):
|
||||||
|
root = col[0]
|
||||||
self._node_cache[root.fspath] = root
|
self._node_cache[root.fspath] = root
|
||||||
|
|
||||||
# If it's a directory argument, recurse and look for any Subpackages.
|
# If it's a directory argument, recurse and look for any Subpackages.
|
||||||
|
|
|
@ -638,6 +638,10 @@ class Test_getinitialnodes(object):
|
||||||
assert col.config is config
|
assert col.config is config
|
||||||
|
|
||||||
def test_pkgfile(self, testdir):
|
def test_pkgfile(self, testdir):
|
||||||
|
"""Verify nesting when a module is within a package.
|
||||||
|
The parent chain should match: Module<x.py> -> Package<subdir> -> Session.
|
||||||
|
Session's parent should always be None.
|
||||||
|
"""
|
||||||
tmpdir = testdir.tmpdir
|
tmpdir = testdir.tmpdir
|
||||||
subdir = tmpdir.join("subdir")
|
subdir = tmpdir.join("subdir")
|
||||||
x = subdir.ensure("x.py")
|
x = subdir.ensure("x.py")
|
||||||
|
@ -645,9 +649,12 @@ class Test_getinitialnodes(object):
|
||||||
with subdir.as_cwd():
|
with subdir.as_cwd():
|
||||||
config = testdir.parseconfigure(x)
|
config = testdir.parseconfigure(x)
|
||||||
col = testdir.getnode(config, x)
|
col = testdir.getnode(config, x)
|
||||||
assert isinstance(col, pytest.Module)
|
|
||||||
assert col.name == "x.py"
|
assert col.name == "x.py"
|
||||||
assert col.parent.parent is None
|
assert isinstance(col, pytest.Module)
|
||||||
|
assert isinstance(col.parent, pytest.Package)
|
||||||
|
assert isinstance(col.parent.parent, pytest.Session)
|
||||||
|
# session is batman (has no parents)
|
||||||
|
assert col.parent.parent.parent is None
|
||||||
for col in col.listchain():
|
for col in col.listchain():
|
||||||
assert col.config is config
|
assert col.config is config
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue