报错信息大概如下:

/Users/alen/anaconda3/lib/python3.7/site-packages/_pytest/config/__init__.py:430: in _importconftest
    return self._conftestpath2mod[conftestpath]
E   KeyError: local('/Users/alen/WorkSpace/txz_repo/repos/DataHub/datahub-common/Python/txz_libs2-develop/txz_libs2/tests/conftest.py')

During handling of the above exception, another exception occurred:
/Users/alen/anaconda3/lib/python3.7/site-packages/_pytest/config/__init__.py:436: in _importconftest
    mod = conftestpath.pyimport()
/Users/alen/anaconda3/lib/python3.7/site-packages/py/_path/local.py:688: in pyimport
    raise self.ImportMismatchError(modname, modfile, self)
E   py._path.local.LocalPath.ImportMismatchError: ('txz_libs2.tests.conftest', '/Users/alen/WorkSpace/tdata_member/DataHub/datahub-common/Python/txz_libs2-develop/txz_libs2/tests/conftest.py', local('/Users/alen/WorkSpace/txz_repo/repos/DataHub/datahub-common/Python/txz_libs2-develop/txz_libs2/tests/conftest.py'))

它的存在是因为pytest在那里缓存了它的重写字节码(它需要重写它以提供带有简单assert的详细断言)。

所以执行以下命令删除字节码即可

find . -name "__pycache__" | xargs -n1 -I{} rm -rf {}