Skip to content

Commit 1de3148

Browse files
msabramodi
authored andcommitted
Add test_long_description_content_type
Test that specifying a `long_description_content_type` keyword arg to the `setup` function results in writing a `Description-Content-Type` line to the `PKG-INFO` file in the `<distribution>.egg-info` directory. `Description-Content-Type` is described at pypa/packaging.python.org#258
1 parent e7a7ee3 commit 1de3148

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

setuptools/tests/test_egg_info.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,31 @@ def test_extras_require_with_invalid_marker_in_req(self, tmpdir_cwd, env):
328328
self._run_install_command(tmpdir_cwd, env)
329329
assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == []
330330

331+
def test_long_description_content_type(self, tmpdir_cwd, env):
332+
# Test that specifying a `long_description_content_type` keyword arg to
333+
# the `setup` function results in writing a `Description-Content-Type`
334+
# line to the `PKG-INFO` file in the `<distribution>.egg-info`
335+
# directory.
336+
# `Description-Content-Type` is described at
337+
# https://github.com/pypa/python-packaging-user-guide/pull/258
338+
339+
self._setup_script_with_requires(
340+
"""long_description_content_type='text/markdown',""")
341+
environ = os.environ.copy().update(
342+
HOME=env.paths['home'],
343+
)
344+
code, data = environment.run_setup_py(
345+
cmd=['egg_info'],
346+
pypath=os.pathsep.join([env.paths['lib'], str(tmpdir_cwd)]),
347+
data_stream=1,
348+
env=environ,
349+
)
350+
egg_info_dir = os.path.join('.', 'foo.egg-info')
351+
with open(os.path.join(egg_info_dir, 'PKG-INFO')) as pkginfo_file:
352+
pkg_info_lines = pkginfo_file.read().split('\n')
353+
expected_line = 'Description-Content-Type: text/markdown'
354+
assert expected_line in pkg_info_lines
355+
331356
def test_python_requires_egg_info(self, tmpdir_cwd, env):
332357
self._setup_script_with_requires(
333358
"""python_requires='>=2.7.12',""")

0 commit comments

Comments
 (0)