diff options
| author | Deniz Taneli <7292227+dtaneli@users.noreply.github.com> | 2018-10-27 16:32:24 +0100 |
|---|---|---|
| committer | Deniz Taneli <7292227+dtaneli@users.noreply.github.com> | 2018-10-27 16:32:24 +0100 |
| commit | 00b172d6b4a4f3fb1546dd0c2fc53ec2d4087b00 (patch) | |
| tree | 498068243644b2afaa9d1e0736466c4d51a08720 | |
| parent | ca0760af2071c333cda28d18279db95455ffa2de (diff) | |
| download | python-setuptools-git-00b172d6b4a4f3fb1546dd0c2fc53ec2d4087b00.tar.gz | |
Unit tests for installing licenses from setup.cfg (#357)
Co-Authored-By: Poyzan Nur Taneli <31743851+ptaneli@users.noreply.github.com>
| -rw-r--r-- | setuptools/tests/test_egg_info.py | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index 59ffb16d..2ca91e85 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -486,6 +486,98 @@ class TestEggInfo: pkg_info_text = pkginfo_file.read() assert 'Provides-Extra:' not in pkg_info_text + def test_setup_cfg_with_license(self, tmpdir_cwd, env): + self._create_project() + build_files({ + 'setup.cfg': DALS(""" + [metadata] + license_file = LICENSE + """), + 'LICENSE': DALS("Test license") + }) + environ = os.environ.copy().update( + HOME=env.paths['home'], + ) + environment.run_setup_py( + cmd=['egg_info'], + pypath=os.pathsep.join([env.paths['lib'], str(tmpdir_cwd)]), + data_stream=1, + env=environ, + ) + egg_info_dir = os.path.join('.', 'foo.egg-info') + with open(os.path.join(egg_info_dir, 'SOURCES.txt')) as sources_file: + sources_text = sources_file.read() + assert 'LICENSE' in sources_text + + def test_setup_cfg_with_invalid_license(self, tmpdir_cwd, env): + self._create_project() + build_files({ + 'setup.cfg': DALS(""" + [metadata] + license_file = INVALID_LICENSE + """), + 'LICENSE': DALS("Test license") + }) + environ = os.environ.copy().update( + HOME=env.paths['home'], + ) + environment.run_setup_py( + cmd=['egg_info'], + pypath=os.pathsep.join([env.paths['lib'], str(tmpdir_cwd)]), + data_stream=1, + env=environ, + ) + egg_info_dir = os.path.join('.', 'foo.egg-info') + with open(os.path.join(egg_info_dir, 'SOURCES.txt')) as sources_file: + sources_text = sources_file.read() + assert 'LICENSE' not in sources_text + assert 'INVALID_LICENSE' not in sources_text + + def test_setup_cfg_with_no_license(self, tmpdir_cwd, env): + self._create_project() + build_files({ + 'setup.cfg': DALS(""" + """), + 'LICENSE': DALS("Test license") + }) + environ = os.environ.copy().update( + HOME=env.paths['home'], + ) + environment.run_setup_py( + cmd=['egg_info'], + pypath=os.pathsep.join([env.paths['lib'], str(tmpdir_cwd)]), + data_stream=1, + env=environ, + ) + egg_info_dir = os.path.join('.', 'foo.egg-info') + with open(os.path.join(egg_info_dir, 'SOURCES.txt')) as sources_file: + sources_text = sources_file.read() + assert 'LICENSE' not in sources_text + + def test_setup_cfg_with_license_excluded(self, tmpdir_cwd, env): + self._create_project() + build_files({ + 'setup.cfg': DALS(""" + [metadata] + license_file = LICENSE + """), + 'MANIFEST.in': DALS("exclude LICENSE"), + 'LICENSE': DALS("Test license") + }) + environ = os.environ.copy().update( + HOME=env.paths['home'], + ) + environment.run_setup_py( + cmd=['egg_info'], + pypath=os.pathsep.join([env.paths['lib'], str(tmpdir_cwd)]), + data_stream=1, + env=environ, + ) + egg_info_dir = os.path.join('.', 'foo.egg-info') + with open(os.path.join(egg_info_dir, 'SOURCES.txt')) as sources_file: + sources_text = sources_file.read() + assert 'LICENSE' not in sources_text + def test_long_description_content_type(self, tmpdir_cwd, env): # Test that specifying a `long_description_content_type` keyword arg to # the `setup` function results in writing a `Description-Content-Type` |
