aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2016-07-31 20:56:26 -0400
committerJason R. Coombs <jaraco@jaraco.com>2016-07-31 20:56:26 -0400
commit8cc9cd3c76ee2ab313163cf2bee54e5ba31f9f6b (patch)
tree95cebca28cc5117c82066329c558498424502aee
parent52f72bb8d233ca518f4782c5dd9569c6764c53ef (diff)
downloadexternal_python_setuptools-8cc9cd3c76ee2ab313163cf2bee54e5ba31f9f6b.tar.gz
external_python_setuptools-8cc9cd3c76ee2ab313163cf2bee54e5ba31f9f6b.tar.bz2
external_python_setuptools-8cc9cd3c76ee2ab313163cf2bee54e5ba31f9f6b.zip
Build metadata programmatically to avoid weird double-newline removal.
-rw-r--r--setuptools/tests/test_dist_info.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/setuptools/tests/test_dist_info.py b/setuptools/tests/test_dist_info.py
index 122d94a0..0d1aed03 100644
--- a/setuptools/tests/test_dist_info.py
+++ b/setuptools/tests/test_dist_info.py
@@ -14,34 +14,39 @@ from .textwrap import DALS
class TestDistInfo:
- metadata_template = DALS("""
+ metadata_base = DALS("""
Metadata-Version: 1.2
- Name: {name}
- {version}
Requires-Dist: splort (==4)
Provides-Extra: baz
Requires-Dist: quux (>=1.1); extra == 'baz'
""")
+ @classmethod
+ def build_metadata(cls, **kwargs):
+ lines = (
+ '{key}: {value}\n'.format(**locals())
+ for key, value in kwargs.items()
+ )
+ return cls.metadata_base + ''.join(lines)
+
@pytest.fixture
def metadata(self, tmpdir):
dist_info_name = 'VersionedDistribution-2.718.dist-info'
versioned = tmpdir / dist_info_name
versioned.mkdir()
filename = versioned / 'METADATA'
- content = self.metadata_template.format(
- name='VersionedDistribution',
- version='',
- ).replace('\n\n', '\n')
+ content = self.build_metadata(
+ Name='VersionedDistribution',
+ )
filename.write_text(content, encoding='utf-8')
dist_info_name = 'UnversionedDistribution.dist-info'
unversioned = tmpdir / dist_info_name
unversioned.mkdir()
filename = unversioned / 'METADATA'
- content = self.metadata_template.format(
- name='UnversionedDistribution',
- version='Version: 0.3',
+ content = self.build_metadata(
+ Name='UnversionedDistribution',
+ Version='0.3',
)
filename.write_text(content, encoding='utf-8')