Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
Test: editable install \w --user&build isolation
Browse files Browse the repository at this point in the history
Add a new test and confirm that it
fails in the expected manner
  • Loading branch information
hexagonrecursion committed Mar 5, 2022
1 parent e8ad85b commit 94ee8d0
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions setuptools/tests/test_easy_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,3 +1109,32 @@ def test_use_correct_python_version_string(tmpdir, tmpdir_cwd, monkeypatch):
assert cmd.config_vars['py_version'] == '3.10.1'
assert cmd.config_vars['py_version_short'] == '3.10'
assert cmd.config_vars['py_version_nodot'] == '310'


def test_editable_install_honors_user_under_build_isolation(setup_context, monkeypatch, tmpdir):
''' `setup.py develop` should honor `--user` even under build isolation'''

## Arrange:
# Pretend that build isolation was enabled
# e.g pip sets the environment varible PYTHONNOUSERSITE=1
monkeypatch.setattr('site.ENABLE_USER_SITE', False)
# The tests should not write to the real ~/.local/lib/ or /usr/local/lib
USER_BASE = (tmpdir / 'user-base').ensure_dir()
monkeypatch.setattr('site.USER_BASE', str(USER_BASE))
sys_prefix = (tmpdir / 'sys_prefix').ensure_dir()
monkeypatch.setattr('sys.prefix', str(sys_prefix))

## Sanity check:
assert sys_prefix.listdir() == []
assert USER_BASE.listdir() == []

## Act:
run_setup('setup.py', ['develop', '--user'])

## Assert:
# Should not install to sys.prefix
with pytest.raises(AssertionError):
assert sys_prefix.listdir() == []
# Should install to site.USER_BASE
with pytest.raises(AssertionError):
assert (USER_BASE / 'lib').isdir()

0 comments on commit 94ee8d0

Please sign in to comment.