Skip to content

Commit

Permalink
Unit tests for installing licenses from setup.cfg (pypa#357)
Browse files Browse the repository at this point in the history
Co-Authored-By: Poyzan Nur Taneli <[email protected]>
  • Loading branch information
dtaneli and poyzannur committed Oct 27, 2018
1 parent ca0760a commit 00b172d
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions setuptools/tests/test_egg_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,98 @@ def test_doesnt_provides_extra(self, tmpdir_cwd, env):
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`
Expand Down

0 comments on commit 00b172d

Please sign in to comment.