diff options
| author | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2022-03-07 23:40:38 +0000 |
|---|---|---|
| committer | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2022-03-07 23:40:38 +0000 |
| commit | e628030fde4138b7bfb713d56fd1150dcbc8ca12 (patch) | |
| tree | c581f81410b9f16ef8913d13d25da63fa8a23451 /setuptools/tests/test_virtualenv.py | |
| parent | 298f5a6368397977ee09cb0b39d5f76aa544b048 (diff) | |
| download | python-setuptools-git-e628030fde4138b7bfb713d56fd1150dcbc8ca12.tar.gz | |
[CI] Disable test_pip_upgrade_from_source when network if off
As discussed in #3149, builds with setuptools will always try to
download `wheel`, therefore if the network is not available there is
little sense in testing those builds (they will fail).
Diffstat (limited to 'setuptools/tests/test_virtualenv.py')
| -rw-r--r-- | setuptools/tests/test_virtualenv.py | 56 |
1 files changed, 20 insertions, 36 deletions
diff --git a/setuptools/tests/test_virtualenv.py b/setuptools/tests/test_virtualenv.py index 0ba89643..65358543 100644 --- a/setuptools/tests/test_virtualenv.py +++ b/setuptools/tests/test_virtualenv.py @@ -1,7 +1,8 @@ import os import sys -import itertools import subprocess +from urllib.request import urlopen +from urllib.error import URLError import pathlib @@ -31,56 +32,39 @@ def test_clean_env_install(venv_without_setuptools, setuptools_wheel): venv_without_setuptools.run(cmd) -def _get_pip_versions(): - # This fixture will attempt to detect if tests are being run without - # network connectivity and if so skip some tests - - network = True +def access_pypi(): + # Detect if tests are being run without connectivity if not os.environ.get('NETWORK_REQUIRED', False): # pragma: nocover try: - from urllib.request import urlopen - from urllib.error import URLError - except ImportError: - from urllib2 import urlopen, URLError # Python 2.7 compat - - try: urlopen('https://pypi.org', timeout=1) except URLError: # No network, disable most of these tests - network = False + return False - def mark(param, *marks): - if not isinstance(param, type(pytest.param(''))): - param = pytest.param(param) - return param._replace(marks=param.marks + marks) + return True - def skip_network(param): - return param if network else mark(param, pytest.mark.skip(reason="no network")) - network_versions = [ - mark('pip<20', pytest.mark.xfail(reason='pypa/pip#6599')), +@pytest.mark.skipif( + 'platform.python_implementation() == "PyPy"', + reason="https://github.com/pypa/setuptools/pull/2865#issuecomment-965834995", +) +@pytest.mark.skipif(not access_pypi(), reason="no network") +# ^-- Even when it is not necessary to install a different version of `pip` +# the build process will still try to download `wheel`, see #3147 and #2986. +@pytest.mark.parametrize( + 'pip_version', + [ + None, + pytest.param('pip<20', marks=pytest.mark.xfail(reason='pypa/pip#6599')), 'pip<20.1', 'pip<21', 'pip<22', - mark( + pytest.param( 'https://github.com/pypa/pip/archive/main.zip', - pytest.mark.xfail(reason='#2975'), + marks=pytest.mark.xfail(reason='#2975'), ), ] - - versions = itertools.chain( - [None], - map(skip_network, network_versions) - ) - - return list(versions) - - -@pytest.mark.skipif( - 'platform.python_implementation() == "PyPy"', - reason="https://github.com/pypa/setuptools/pull/2865#issuecomment-965834995", ) -@pytest.mark.parametrize('pip_version', _get_pip_versions()) def test_pip_upgrade_from_source(pip_version, venv_without_setuptools, setuptools_wheel, setuptools_sdist): """ |
