Fix test collection when tests are passed as IDs at the command line. Note this is still broken due to #3358.

This commit is contained in:
turturica 2018-04-16 11:44:05 -07:00
parent 35df2cdbee
commit c02e8d8b0d
3 changed files with 7 additions and 4 deletions

View File

@ -423,9 +423,12 @@ class Session(nodes.FSCollector):
else:
assert argpath.check(file=1)
pkginit = argpath.dirpath().join('__init__.py')
if not self.isinitpath(argpath) and pkginit.exists():
if not self.isinitpath(pkginit):
self._initialpaths.add(pkginit)
if pkginit.exists():
for x in self._collectfile(pkginit):
yield x
for y in self.matchnodes(x._collectfile(argpath), names):
yield y
else:
for x in self.matchnodes(self._collectfile(argpath), names):
yield x

View File

@ -927,7 +927,7 @@ def test_setup_only_available_in_subdir(testdir):
def test_modulecol_roundtrip(testdir):
modcol = testdir.getmodulecol("pass", withinit=True)
modcol = testdir.getmodulecol("pass", withinit=False)
trail = modcol.nodeid
newcol = modcol.session.perform_collect([trail], genitems=0)[0]
assert modcol.name == newcol.name

View File

@ -587,7 +587,7 @@ class Test_getinitialnodes(object):
col = testdir.getnode(config, x)
assert isinstance(col, pytest.Module)
assert col.name == 'x.py'
assert col.parent.parent is None
assert col.parent.parent.parent is None
for col in col.listchain():
assert col.config is config