jupyter-packaging
jupyter-packaging copied to clipboard
Running pytest fails if pip doesn't have permissions to install packages
The problem seems to be in tests/test_datafiles_install.py which tries to execute a bare pip install .
A somewhat easy workaround would be to set up a temporary directory and export PIP_TARGET=/path/to/tmp/staging before running each test that tries to pip install.
UPDATE: Also seems to affect tests/test_install.py.
Also, it would be nice to make it possible to easily skip those tests in environments without internet access.
Oh, I misunderstand the issue, sorry. Now I see it. If I run the tests as a regular user, it tries to install packages into /usr/jupyter-packaging-test… which is not possible for obvious reasons. It seems that the tests are using sys.base_prefix as a root directory. Wouldn't it be better to use pytest fixture tmp_path?
Taking note of two things we need for this:
- Add a pytest marker for tests that require downloads
- Use a pytest fixture that creates a venv for anything that is going to invoke pip install