diff options
author | 2017-03-29 13:35:45 +0300 | |
---|---|---|
committer | 2017-03-29 13:35:45 +0300 | |
commit | e2cc2530fc6d54ebc975c01a4ff887ce12f0a736 (patch) | |
tree | 38385867295c8a09fb0d7f8eaf5fa78179e5b13a /jython-tosca-parser/src/main/resources/Lib/site-packages/setuptools/tests/test_dist_info.py | |
parent | bccebaa9888906f8ff78172f62ec592956066d82 (diff) |
[SDC-6] sdc-distribution-client 1707 rebasing
Change-Id: I322a05fd79beb6ba4fee4d32afffecf531b86e98
Signed-off-by: Pavel Aharoni <pa0916@att.com>
Diffstat (limited to 'jython-tosca-parser/src/main/resources/Lib/site-packages/setuptools/tests/test_dist_info.py')
-rw-r--r-- | jython-tosca-parser/src/main/resources/Lib/site-packages/setuptools/tests/test_dist_info.py | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/setuptools/tests/test_dist_info.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/setuptools/tests/test_dist_info.py new file mode 100644 index 0000000..6d0ab58 --- /dev/null +++ b/jython-tosca-parser/src/main/resources/Lib/site-packages/setuptools/tests/test_dist_info.py @@ -0,0 +1,70 @@ +"""Test .dist-info style distributions. +""" +import os +import shutil +import tempfile + +import pytest + +import pkg_resources +from .textwrap import DALS + + +class TestDistInfo: + + def test_distinfo(self): + dists = dict( + (d.project_name, d) + for d in pkg_resources.find_distributions(self.tmpdir) + ) + + assert len(dists) == 2, dists + + unversioned = dists['UnversionedDistribution'] + versioned = dists['VersionedDistribution'] + + assert versioned.version == '2.718' # from filename + assert unversioned.version == '0.3' # from METADATA + + @pytest.mark.importorskip('ast') + def test_conditional_dependencies(self): + specs = 'splort==4', 'quux>=1.1' + requires = list(map(pkg_resources.Requirement.parse, specs)) + + for d in pkg_resources.find_distributions(self.tmpdir): + assert d.requires() == requires[:1] + assert d.requires(extras=('baz',)) == requires + assert d.extras == ['baz'] + + metadata_template = DALS(""" + Metadata-Version: 1.2 + Name: {name} + {version} + Requires-Dist: splort (==4) + Provides-Extra: baz + Requires-Dist: quux (>=1.1); extra == 'baz' + """) + + def setup_method(self, method): + self.tmpdir = tempfile.mkdtemp() + dist_info_name = 'VersionedDistribution-2.718.dist-info' + versioned = os.path.join(self.tmpdir, dist_info_name) + os.mkdir(versioned) + with open(os.path.join(versioned, 'METADATA'), 'w+') as metadata_file: + metadata = self.metadata_template.format( + name='VersionedDistribution', + version='', + ).replace('\n\n', '\n') + metadata_file.write(metadata) + dist_info_name = 'UnversionedDistribution.dist-info' + unversioned = os.path.join(self.tmpdir, dist_info_name) + os.mkdir(unversioned) + with open(os.path.join(unversioned, 'METADATA'), 'w+') as metadata_file: + metadata = self.metadata_template.format( + name='UnversionedDistribution', + version='Version: 0.3', + ) + metadata_file.write(metadata) + + def teardown_method(self, method): + shutil.rmtree(self.tmpdir) |