|
| 1 | +""" |
| 2 | +integration tests that check setuptools version support |
| 3 | +""" |
| 4 | +import sys |
| 5 | +import os |
| 6 | +import subprocess |
| 7 | +import pytest |
| 8 | +pytestmark = pytest.mark.skipif( |
| 9 | + "sys.version_info >= (3,6,0)", |
| 10 | + reason="integration with old versions no longer needed on py3.6+") |
| 11 | + |
| 12 | + |
| 13 | +@pytest.fixture(scope='session') |
| 14 | +def get_setuptools_packagedir(request): |
| 15 | + targets = request.config.cache.makedir('setuptools_installs') |
| 16 | + |
| 17 | + def makeinstall(version): |
| 18 | + target = targets.ensure(version, dir=1) |
| 19 | + subprocess.check_call([ |
| 20 | + sys.executable, '-m', 'pip', |
| 21 | + 'install', '--no-binary', 'setuptools', 'setuptools==' + version, |
| 22 | + '-t', str(target), |
| 23 | + ]) |
| 24 | + return target |
| 25 | + return makeinstall |
| 26 | + |
| 27 | + |
| 28 | +SCRIPT = """ |
| 29 | +import setuptools |
| 30 | +print(setuptools.__version__) |
| 31 | +import setuptools_scm.version |
| 32 | +from setuptools_scm.__main__ import main |
| 33 | +main() |
| 34 | +""" |
| 35 | + |
| 36 | + |
| 37 | +def check(packagedir, **env): |
| 38 | + subprocess.check_call( |
| 39 | + [sys.executable, '-c', SCRIPT], |
| 40 | + env=dict(os.environ, PYTHONPATH=".:" + str(packagedir), **env)) |
| 41 | + |
| 42 | + |
| 43 | +def test_old_setuptools_fails(get_setuptools_packagedir): |
| 44 | + packagedir = get_setuptools_packagedir("0.9.8") |
| 45 | + with pytest.raises(subprocess.CalledProcessError): |
| 46 | + check(packagedir) |
| 47 | + |
| 48 | + |
| 49 | +def test_old_setuptools_allows_with_warnings(get_setuptools_packagedir): |
| 50 | + |
| 51 | + packagedir = get_setuptools_packagedir("0.9.8") |
| 52 | + # filter using warning since in the early python startup |
| 53 | + check( |
| 54 | + packagedir, |
| 55 | + PYTHONWARNINGS="once::Warning") |
| 56 | + |
| 57 | + |
| 58 | +def test_distlib_setuptools_works(get_setuptools_packagedir): |
| 59 | + packagedir = get_setuptools_packagedir("12.0.1") |
| 60 | + check(packagedir) |
0 commit comments