pip/pipenv leaving behind extra build directory breaking unit tests
A recent version of pip(/pipenv?) seems to leave behind the temporary build directory. This breaks pytests pathfinding as it gets confused between the multiple copies of conftest.py
The temporary fix is to delete the build
directory. Ideally we should work out what change has caused this to start happening and ideally get it to remove the build directory or at least get pytest to ignore it.
$ pipenv run unit-test
Loading .env environment variables…
Starting hotpotato_cockroach_1 ... done
Starting hotpotato_rabbitmq_1 ... done
Starting hotpotato_theme_1 ... done
Starting hotpotato_hotpotato-workers_1 ... done
=============================================================================================== test session starts ================================================================================================
platform linux -- Python 3.6.11, pytest-5.2.2, py-1.8.0, pluggy-0.13.0
rootdir: /code, inifile: setup.cfg
plugins: cov-2.8.1
collected 0 items / 1 errors
Coverage.py warning: No data was collected. (no-data-collected)
====================================================================================================== ERRORS ======================================================================================================
__________________________________________________________________________________________ ERROR collecting test session ___________________________________________________________________________________________
/venv/lib/python3.6/site-packages/_pytest/config/__init__.py:451: in _importconftest
return self._conftestpath2mod[key]
E KeyError: PosixPath('/code/hotpotato/tests/conftest.py')
During handling of the above exception, another exception occurred:
/venv/lib/python3.6/site-packages/_pytest/config/__init__.py:457: in _importconftest
mod = conftestpath.pyimport()
/venv/lib/python3.6/site-packages/py/_path/local.py:721: in pyimport
raise self.ImportMismatchError(modname, modfile, self)
E py._path.local.LocalPath.ImportMismatchError: ('hotpotato.tests.conftest', '/code/build/lib/hotpotato/tests/conftest.py', local('/code/hotpotato/tests/conftest.py'))
During handling of the above exception, another exception occurred:
/venv/lib/python3.6/site-packages/py/_path/common.py:377: in visit
for x in Visitor(fil, rec, ignore, bf, sort).gen(self):
/venv/lib/python3.6/site-packages/py/_path/common.py:429: in gen
for p in self.gen(subdir):
/venv/lib/python3.6/site-packages/py/_path/common.py:418: in gen
dirs = self.optsort([p for p in entries
/venv/lib/python3.6/site-packages/py/_path/common.py:419: in <listcomp>
if p.check(dir=1) and (rec is None or rec(p))])
/venv/lib/python3.6/site-packages/_pytest/main.py:608: in _recurse
ihook = self.gethookproxy(dirpath)
/venv/lib/python3.6/site-packages/_pytest/main.py:426: in gethookproxy
my_conftestmodules = pm._getconftestmodules(fspath)
/venv/lib/python3.6/site-packages/_pytest/config/__init__.py:429: in _getconftestmodules
mod = self._importconftest(conftestpath)
/venv/lib/python3.6/site-packages/_pytest/config/__init__.py:465: in _importconftest
raise ConftestImportFailure(conftestpath, sys.exc_info())
E _pytest.config.ConftestImportFailure: (local('/code/hotpotato/tests/conftest.py'), (<class 'py._path.local.LocalPath.ImportMismatchError'>, ImportMismatchError('hotpotato.tests.conftest', '/code/build/lib/hotpotato/tests/conftest.py', local('/code/hotpotato/tests/conftest.py')), <traceback object at 0x7f28fbe0fb48>))
================================================================================================= warnings summary =================================================================================================
/venv/lib/python3.6/site-packages/flask_babelex/__init__.py:23
/venv/lib/python3.6/site-packages/flask_babelex/__init__.py:23: DeprecationWarning: The import 'werkzeug.ImmutableDict' is deprecated and will be removed in Werkzeug 1.0. Use 'from werkzeug.datastructures import ImmutableDict' instead.
from werkzeug import ImmutableDict
/venv/lib/python3.6/site-packages/flask_wtf/recaptcha/widgets.py:5
/venv/lib/python3.6/site-packages/flask_wtf/recaptcha/widgets.py:5: DeprecationWarning: The import 'werkzeug.url_encode' is deprecated and will be removed in Werkzeug 1.0. Use 'from werkzeug.urls import url_encode' instead.
from werkzeug import url_encode
-- Docs: https://docs.pytest.org/en/latest/warnings.html
---------- coverage: platform linux, python 3.6.11-final-0 -----------
Coverage HTML written to dir ../log/coverage
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=========================================================================================== 2 warnings, 1 error in 4.18s ===========================================================================================
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information