aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/tests/test_egg_info.py
diff options
context:
space:
mode:
authorMick Koch <mick@kochm.co>2019-05-20 18:25:19 -0400
committerMick Koch <mick@kochm.co>2019-10-28 18:30:31 -0400
commit823ab9d2ec4ab89f90c0a781d872c9071b4afc13 (patch)
tree8c6e9f23a72bb970b8d01592aacaee4e71a442bb /setuptools/tests/test_egg_info.py
parent7748921de342160ca2dc9c9539562bb9c924e14c (diff)
downloadexternal_python_setuptools-823ab9d2ec4ab89f90c0a781d872c9071b4afc13.tar.gz
external_python_setuptools-823ab9d2ec4ab89f90c0a781d872c9071b4afc13.tar.bz2
external_python_setuptools-823ab9d2ec4ab89f90c0a781d872c9071b4afc13.zip
Add support for `license_files` option in metadata
Diffstat (limited to 'setuptools/tests/test_egg_info.py')
-rw-r--r--setuptools/tests/test_egg_info.py198
1 files changed, 198 insertions, 0 deletions
diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py
index 316eb2ed..61da1bda 100644
--- a/setuptools/tests/test_egg_info.py
+++ b/setuptools/tests/test_egg_info.py
@@ -567,6 +567,204 @@ class TestEggInfo:
assert 'LICENSE' not in sources_text
assert 'INVALID_LICENSE' not in sources_text # for invalid license test
+ @pytest.mark.parametrize("files, incl_licenses, excl_licenses", [
+ ({
+ 'setup.cfg': DALS("""
+ [metadata]
+ license_files =
+ LICENSE-ABC
+ LICENSE-XYZ
+ """),
+ 'LICENSE-ABC': DALS("ABC license"),
+ 'LICENSE-XYZ': DALS("XYZ license")
+ }, ['LICENSE-ABC', 'LICENSE-XYZ'], []), # with licenses
+ ({
+ 'setup.cfg': DALS("""
+ [metadata]
+ license_files = LICENSE-ABC, LICENSE-XYZ
+ """),
+ 'LICENSE-ABC': DALS("ABC license"),
+ 'LICENSE-XYZ': DALS("XYZ license")
+ }, ['LICENSE-ABC', 'LICENSE-XYZ'], []), # with commas
+ ({
+ 'setup.cfg': DALS("""
+ [metadata]
+ license_files =
+ LICENSE-ABC
+ """),
+ 'LICENSE-ABC': DALS("ABC license"),
+ 'LICENSE-XYZ': DALS("XYZ license")
+ }, ['LICENSE-ABC'], ['LICENSE-XYZ']), # with one license
+ ({
+ 'setup.cfg': DALS("""
+ [metadata]
+ license_files =
+ """),
+ 'LICENSE-ABC': DALS("ABC license"),
+ 'LICENSE-XYZ': DALS("XYZ license")
+ }, [], ['LICENSE-ABC', 'LICENSE-XYZ']), # empty
+ ({
+ 'setup.cfg': DALS("""
+ [metadata]
+ license_files = LICENSE-XYZ
+ """),
+ 'LICENSE-ABC': DALS("ABC license"),
+ 'LICENSE-XYZ': DALS("XYZ license")
+ }, ['LICENSE-XYZ'], ['LICENSE-ABC']), # on same line
+ ({
+ 'setup.cfg': DALS("""
+ [metadata]
+ license_files =
+ LICENSE-ABC
+ INVALID_LICENSE
+ """),
+ 'LICENSE-ABC': DALS("Test license")
+ }, ['LICENSE-ABC'], ['INVALID_LICENSE']), # with an invalid license
+ ({
+ 'setup.cfg': DALS("""
+ """),
+ 'LICENSE': DALS("Test license")
+ }, [], ['LICENSE']), # no license_files attribute
+ ({
+ 'setup.cfg': DALS("""
+ [metadata]
+ license_files = LICENSE
+ """),
+ 'MANIFEST.in': DALS("exclude LICENSE"),
+ 'LICENSE': DALS("Test license")
+ }, [], ['LICENSE']), # license file is manually excluded
+ ({
+ 'setup.cfg': DALS("""
+ [metadata]
+ license_files =
+ LICENSE-ABC
+ LICENSE-XYZ
+ """),
+ 'MANIFEST.in': DALS("exclude LICENSE-XYZ"),
+ 'LICENSE-ABC': DALS("ABC license"),
+ 'LICENSE-XYZ': DALS("XYZ license")
+ }, ['LICENSE-ABC'], ['LICENSE-XYZ']) # subset is manually excluded
+ ])
+ def test_setup_cfg_license_files(
+ self, tmpdir_cwd, env, files, incl_licenses, excl_licenses):
+ self._create_project()
+ build_files(files)
+
+ environment.run_setup_py(
+ cmd=['egg_info'],
+ pypath=os.pathsep.join([env.paths['lib'], str(tmpdir_cwd)])
+ )
+ egg_info_dir = os.path.join('.', 'foo.egg-info')
+
+ with open(os.path.join(egg_info_dir, 'SOURCES.txt')) as sources_file:
+ sources_lines = list(line.strip() for line in sources_file)
+
+ for lf in incl_licenses:
+ assert sources_lines.count(lf) == 1
+
+ for lf in excl_licenses:
+ assert sources_lines.count(lf) == 0
+
+ @pytest.mark.parametrize("files, incl_licenses, excl_licenses", [
+ ({
+ 'setup.cfg': DALS("""
+ [metadata]
+ license_file =
+ license_files =
+ """),
+ 'LICENSE-ABC': DALS("ABC license"),
+ 'LICENSE-XYZ': DALS("XYZ license")
+ }, [], ['LICENSE-ABC', 'LICENSE-XYZ']), # both empty
+ ({
+ 'setup.cfg': DALS("""
+ [metadata]
+ license_file =
+ LICENSE-ABC
+ LICENSE-XYZ
+ """),
+ 'LICENSE-ABC': DALS("ABC license"),
+ 'LICENSE-XYZ': DALS("XYZ license")
+ }, [], ['LICENSE-ABC', 'LICENSE-XYZ']), # license_file is still singular
+ ({
+ 'setup.cfg': DALS("""
+ [metadata]
+ license_file = LICENSE-ABC
+ license_files =
+ LICENSE-XYZ
+ LICENSE-PQR
+ """),
+ 'LICENSE-ABC': DALS("ABC license"),
+ 'LICENSE-PQR': DALS("PQR license"),
+ 'LICENSE-XYZ': DALS("XYZ license")
+ }, ['LICENSE-ABC', 'LICENSE-PQR', 'LICENSE-XYZ'], []), # combined
+ ({
+ 'setup.cfg': DALS("""
+ [metadata]
+ license_file = LICENSE-ABC
+ license_files =
+ LICENSE-ABC
+ LICENSE-XYZ
+ LICENSE-PQR
+ """),
+ 'LICENSE-ABC': DALS("ABC license"),
+ 'LICENSE-PQR': DALS("PQR license"),
+ 'LICENSE-XYZ': DALS("XYZ license")
+ }, ['LICENSE-ABC', 'LICENSE-PQR', 'LICENSE-XYZ'], []), # duplicate license
+ ({
+ 'setup.cfg': DALS("""
+ [metadata]
+ license_file = LICENSE-ABC
+ license_files =
+ LICENSE-XYZ
+ """),
+ 'LICENSE-ABC': DALS("ABC license"),
+ 'LICENSE-PQR': DALS("PQR license"),
+ 'LICENSE-XYZ': DALS("XYZ license")
+ }, ['LICENSE-ABC', 'LICENSE-XYZ'], ['LICENSE-PQR']), # combined subset
+ ({
+ 'setup.cfg': DALS("""
+ [metadata]
+ license_file = LICENSE-ABC
+ license_files =
+ LICENSE-XYZ
+ LICENSE-PQR
+ """),
+ 'LICENSE-PQR': DALS("Test license")
+ }, ['LICENSE-PQR'], ['LICENSE-ABC', 'LICENSE-XYZ']), # with invalid licenses
+ ({
+ 'setup.cfg': DALS("""
+ [metadata]
+ license_file = LICENSE-ABC
+ license_files =
+ LICENSE-PQR
+ LICENSE-XYZ
+ """),
+ 'MANIFEST.in': DALS("exclude LICENSE-ABC\nexclude LICENSE-PQR"),
+ 'LICENSE-ABC': DALS("ABC license"),
+ 'LICENSE-PQR': DALS("PQR license"),
+ 'LICENSE-XYZ': DALS("XYZ license")
+ }, ['LICENSE-XYZ'], ['LICENSE-ABC', 'LICENSE-PQR']) # manually excluded
+ ])
+ def test_setup_cfg_license_file_license_files(
+ self, tmpdir_cwd, env, files, incl_licenses, excl_licenses):
+ self._create_project()
+ build_files(files)
+
+ environment.run_setup_py(
+ cmd=['egg_info'],
+ pypath=os.pathsep.join([env.paths['lib'], str(tmpdir_cwd)])
+ )
+ egg_info_dir = os.path.join('.', 'foo.egg-info')
+
+ with open(os.path.join(egg_info_dir, 'SOURCES.txt')) as sources_file:
+ sources_lines = list(line.strip() for line in sources_file)
+
+ for lf in incl_licenses:
+ assert sources_lines.count(lf) == 1
+
+ for lf in excl_licenses:
+ assert sources_lines.count(lf) == 0
+
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`