CI: ImportMismatchError when running on swh-graph
All CI runs for swh-graph fail during pytest test collection. Quoting from a recent example:
============================= test session starts ==============================
platform linux -- Python 3.7.3, pytest-5.2.2, py-1.8.0, pluggy-0.13.0
cachedir: .tox/py3/.pytest_cache
rootdir: /home/jenkins/workspace/DGRPH/tests, inifile: pytest.ini
plugins: cov-2.8.1, swh.core-0.0.76, hypothesis-4.42.10
collected 0 items / 1 errors
==================================== ERRORS ====================================
________________________ ERROR collecting test session _________________________
.tox/py3/lib/python3.7/site-packages/_pytest/config/__init__.py:451: in _importconftest
return self._conftestpath2mod[key]
E KeyError: PosixPath('/home/jenkins/workspace/DGRPH/tests/swh/graph/tests/conftest.py')
During handling of the above exception, another exception occurred:
.tox/py3/lib/python3.7/site-packages/_pytest/config/__init__.py:457: in _importconftest
mod = conftestpath.pyimport()
.tox/py3/lib/python3.7/site-packages/py/_path/local.py:721: in pyimport
raise self.ImportMismatchError(modname, modfile, self)
E py._path.local.LocalPath.ImportMismatchError: ('swh.graph.tests.conftest', '/home/jenkins/workspace/DGRPH/tests/.tox/py3/lib/python3.7/site-packages/swh/graph/tests/conftest.py', local('/home/jenkins/workspace/DGRPH/tests/swh/graph/tests/conftest.py'))
During handling of the above exception, another exception occurred:
.tox/py3/lib/python3.7/site-packages/py/_path/common.py:377: in visit
for x in Visitor(fil, rec, ignore, bf, sort).gen(self):
.tox/py3/lib/python3.7/site-packages/py/_path/common.py:429: in gen
for p in self.gen(subdir):
.tox/py3/lib/python3.7/site-packages/py/_path/common.py:429: in gen
for p in self.gen(subdir):
.tox/py3/lib/python3.7/site-packages/py/_path/common.py:418: in gen
dirs = self.optsort([p for p in entries
.tox/py3/lib/python3.7/site-packages/py/_path/common.py:419: in <listcomp>
if p.check(dir=1) and (rec is None or rec(p))])
.tox/py3/lib/python3.7/site-packages/_pytest/main.py:608: in _recurse
ihook = self.gethookproxy(dirpath)
.tox/py3/lib/python3.7/site-packages/_pytest/main.py:426: in gethookproxy
my_conftestmodules = pm._getconftestmodules(fspath)
.tox/py3/lib/python3.7/site-packages/_pytest/config/__init__.py:429: in _getconftestmodules
mod = self._importconftest(conftestpath)
.tox/py3/lib/python3.7/site-packages/_pytest/config/__init__.py:465: in _importconftest
raise ConftestImportFailure(conftestpath, sys.exc_info())
E _pytest.config.ConftestImportFailure: (local('/home/jenkins/workspace/DGRPH/tests/swh/graph/tests/conftest.py'), (<class 'py._path.local.LocalPath.ImportMismatchError'>, ImportMismatchError('swh.graph.tests.conftest', '/home/jenkins/workspace/DGRPH/tests/.tox/py3/lib/python3.7/site-packages/swh/graph/tests/conftest.py', local('/home/jenkins/workspace/DGRPH/tests/swh/graph/tests/conftest.py')), <traceback object at 0x7f8778a6a408>))
Random googling suggests an unclean CI environment in terms of python caches.
Migrated from T2054 (view on Phabricator)
Edited by Phabricator Migration user