diff options
| author | Alex Grönholm <alex.gronholm@nextday.fi> | 2018-07-16 21:04:35 +0300 |
|---|---|---|
| committer | Alex Grönholm <alex.gronholm@nextday.fi> | 2018-07-17 15:02:50 +0300 |
| commit | 59976ab294e1b118f42cab404d95df66ed55f7e4 (patch) | |
| tree | b74f50d731fb5c89e5520bd5ae3f7509d0ce46ee /tests | |
| parent | 61f1aac7a445d4bc0314795c3fb3eee83092fb30 (diff) | |
| download | wheel-git-59976ab294e1b118f42cab404d95df66ed55f7e4.tar.gz | |
Added the license_files option and deprecated license_file
Fixes #138.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_bdist_wheel.py | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/test_bdist_wheel.py b/tests/test_bdist_wheel.py index 891b7fc..f51c6b3 100644 --- a/tests/test_bdist_wheel.py +++ b/tests/test_bdist_wheel.py @@ -1,6 +1,40 @@ # coding: utf-8 +import subprocess +import sys from zipfile import ZipFile +import pytest + +from wheel.wheelfile import WheelFile + +DEFAULT_FILES = { + 'dummy_dist-1.0.dist-info/top_level.txt', + 'dummy_dist-1.0.dist-info/METADATA', + 'dummy_dist-1.0.dist-info/WHEEL', + 'dummy_dist-1.0.dist-info/RECORD' +} +DEFAULT_LICENSE_FILES = { + 'LICENSE', 'LICENSE.txt', 'LICENCE', 'LICENSE.txt', 'COPYING', 'NOTICE' +} + + +@pytest.fixture(scope='module') +def dummy_dist(tmpdir_factory): + basedir = tmpdir_factory.mktemp('dummy_dist') + basedir.join('setup.py').write("""\ +from setuptools import setup + +setup( + name='dummy_dist', + version='1.0' +) +""") + for fname in DEFAULT_LICENSE_FILES: + basedir.join(fname).write('') + + basedir.join('licenses').mkdir().join('DUMMYFILE').write('') + return basedir + def test_no_scripts(wheel_paths): """Make sure entry point scripts are not generated.""" @@ -15,3 +49,41 @@ def test_unicode_record(wheel_paths): record = zf.read('unicode.dist-0.1.dist-info/RECORD') assert u'åäö_日本語.py'.encode('utf-8') in record + + +def test_licenses_default(dummy_dist, monkeypatch, tmpdir): + monkeypatch.chdir(dummy_dist) + subprocess.check_call([sys.executable, 'setup.py', 'bdist_wheel', '-b', str(tmpdir), + '--universal']) + with WheelFile('dist/dummy_dist-1.0-py2.py3-none-any.whl') as wf: + license_files = {'dummy_dist-1.0.dist-info/' + fname for fname in DEFAULT_LICENSE_FILES} + assert set(wf.namelist()) == DEFAULT_FILES | license_files + + +def test_licenses_deprecated(dummy_dist, monkeypatch, tmpdir): + dummy_dist.join('setup.cfg').write('[metadata]\nlicense_file=licenses/DUMMYFILE') + monkeypatch.chdir(dummy_dist) + subprocess.check_call([sys.executable, 'setup.py', 'bdist_wheel', '-b', str(tmpdir), + '--universal']) + with WheelFile('dist/dummy_dist-1.0-py2.py3-none-any.whl') as wf: + license_files = {'dummy_dist-1.0.dist-info/DUMMYFILE'} + assert set(wf.namelist()) == DEFAULT_FILES | license_files + + +def test_licenses_override(dummy_dist, monkeypatch, tmpdir): + dummy_dist.join('setup.cfg').write('[metadata]\nlicense_files=licenses/*\n LICENSE') + monkeypatch.chdir(dummy_dist) + subprocess.check_call([sys.executable, 'setup.py', 'bdist_wheel', '-b', str(tmpdir), + '--universal']) + with WheelFile('dist/dummy_dist-1.0-py2.py3-none-any.whl') as wf: + license_files = {'dummy_dist-1.0.dist-info/' + fname for fname in {'DUMMYFILE', 'LICENSE'}} + assert set(wf.namelist()) == DEFAULT_FILES | license_files + + +def test_licenses_disabled(dummy_dist, monkeypatch, tmpdir): + dummy_dist.join('setup.cfg').write('[metadata]\nlicense_files=\n') + monkeypatch.chdir(dummy_dist) + subprocess.check_call([sys.executable, 'setup.py', 'bdist_wheel', '-b', str(tmpdir), + '--universal']) + with WheelFile('dist/dummy_dist-1.0-py2.py3-none-any.whl') as wf: + assert set(wf.namelist()) == DEFAULT_FILES |
