diff options
author | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2022-01-14 08:42:38 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-14 08:42:38 +0000 |
commit | 4f29f1575911d3b18b93ca76dd31855ded32cb38 (patch) | |
tree | 93abe14f818e8704478c41b8cc900179254f645f | |
parent | 2ec2ba50320492dcb901ce2b6bc98765779bbffe (diff) | |
parent | f1ee2ad4a45739dc73f4de31a74ad97179b5fdca (diff) | |
download | python-setuptools-git-4f29f1575911d3b18b93ca76dd31855ded32cb38.tar.gz |
Merge pull request #3028 from abravalheri/improve-310-test
Fix failing test when user site-packages has no version number
-rw-r--r-- | setuptools/tests/test_easy_install.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 4a2c2537..83ce7f45 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -1065,11 +1065,6 @@ class TestWindowsScriptWriter: VersionStub = namedtuple("VersionStub", "major, minor, micro, releaselevel, serial") -@pytest.mark.skipif( - os.name == 'nt', - reason='Installation schemes for Windows may use values for interpolation ' - 'that come directly from sysconfig and are difficult to patch/mock' -) def test_use_correct_python_version_string(tmpdir, tmpdir_cwd, monkeypatch): # In issue #3001, easy_install wrongly uses the `python3.1` directory # when the interpreter is `python3.10` and the `--user` option is given. @@ -1095,11 +1090,18 @@ def test_use_correct_python_version_string(tmpdir, tmpdir_cwd, monkeypatch): patch.setattr(cmd, 'create_home_path', mock.Mock()) cmd.finalize_options() - if os.getenv('SETUPTOOLS_USE_DISTUTILS', 'local') == 'local': - # Installation schemes in stdlib distutils might be outdated/bugged - name = "pypy" if hasattr(sys, 'pypy_version_info') else "python" - install_dir = cmd.install_dir.lower() - assert f"{name}3.10" in install_dir or f"{name}310" in install_dir + name = "pypy" if hasattr(sys, 'pypy_version_info') else "python" + install_dir = cmd.install_dir.lower() + + # In some platforms (e.g. Windows), install_dir is mostly determined + # via `sysconfig`, which define constants eagerly at module creation. + # This means that monkeypatching `sys.version` to emulate 3.10 for testing + # may have no effect. + # The safest test here is to rely on the fact that 3.1 is no longer + # supported/tested, and make sure that if 'python3.1' ever appears in the string + # it is followed by another digit (e.g. 'python3.10'). + if re.search(name + r'3\.?1', install_dir): + assert re.search(name + r'3\.?1\d', install_dir) # The following "variables" are used for interpolation in distutils # installation schemes, so it should be fair to treat them as "semi-public", |