jupyter-packaging icon indicating copy to clipboard operation
jupyter-packaging copied to clipboard

Running pytest fails if pip doesn't have permissions to install packages

Open filbranden opened this issue 4 years ago • 3 comments

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.

filbranden avatar Jan 08 '21 19:01 filbranden

Also, it would be nice to make it possible to easily skip those tests in environments without internet access.

frenzymadness avatar Jun 24 '21 11:06 frenzymadness

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?

frenzymadness avatar Jun 24 '21 11:06 frenzymadness

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

blink1073 avatar Apr 07 '22 20:04 blink1073