summaryrefslogtreecommitdiff
path: root/distutils2/tests/test_util.py
diff options
context:
space:
mode:
author?ric Araujo <merwok@netwok.org>2012-05-21 16:54:12 -0400
committer?ric Araujo <merwok@netwok.org>2012-05-21 16:54:12 -0400
commitee6fb9f7f0863a1d0020d57f224947f7b795df6d (patch)
treeb8d155316b2f697621264a83a0ef2ef2802c6859 /distutils2/tests/test_util.py
parentc57cf8ba29e0b51e614cac580413a183061834d5 (diff)
parent1ed1781f2170be33392c3056f239766b1b1c6a58 (diff)
downloaddisutils2-ee6fb9f7f0863a1d0020d57f224947f7b795df6d.tar.gz
Merge default
Diffstat (limited to 'distutils2/tests/test_util.py')
-rw-r--r--distutils2/tests/test_util.py57
1 files changed, 51 insertions, 6 deletions
diff --git a/distutils2/tests/test_util.py b/distutils2/tests/test_util.py
index c968e83..1c657fe 100644
--- a/distutils2/tests/test_util.py
+++ b/distutils2/tests/test_util.py
@@ -19,7 +19,8 @@ from distutils2.util import (
get_compiler_versions, _MAC_OS_X_LD_VERSION, byte_compile, find_packages,
spawn, get_pypirc_path, generate_pypirc, read_pypirc, resolve_name, iglob,
RICH_GLOB, egginfo_to_distinfo, is_setuptools, is_distutils, is_packaging,
- get_install_method, cfg_to_args, generate_setup_py, encode_multipart)
+ get_install_method, cfg_to_args, generate_setup_py, encode_multipart,
+ parse_requires)
from distutils2.tests import support, unittest
from distutils2.tests.test_config import SETUP_CFG
@@ -377,6 +378,15 @@ class UtilTestCase(support.EnvironRestorer,
self.assertEqual(sorted(res),
['pkg1', 'pkg1.pkg3', 'pkg1.pkg3.pkg6', 'pkg5'])
+ def test_parse_requires(self):
+ req_file = os.path.join(os.path.dirname(__file__), 'requires.txt')
+ expected_requires = ['setuptools', 'zope.browser', 'zope.component',
+ 'zope.configuration', 'zope.contenttype', 'zope.event',
+ 'zope.exceptions', 'zope.i18n', 'zope.interface',
+ 'zope.location', 'zope.proxy', 'zope.security']
+ requires = parse_requires(req_file)
+ self.assertEqual(requires, expected_requires)
+
def test_resolve_name(self):
# test raw module name
tmpdir = self.mkdtemp()
@@ -744,6 +754,31 @@ class GlobTestCase(GlobTestCaseBase):
self.assertRaises(ValueError, iglob, pattern)
+PKG_INFO = '''\
+Metadata-Version: 1.1
+Name: hello
+Version: 0.1.1
+Summary: Hello World
+Home-page: https://example.com
+Author: John Doe
+Author-email: j.doe@example.com
+License: UNKNOWN
+Download-URL: https://example.com/tarball/master
+Description: UNKNOWN
+Platform: Any
+Classifier: Development Status :: 3 - Alpha
+Classifier: License :: OSI Approved :: Apache Software License
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.2
+Classifier: Intended Audience :: Developers
+Classifier: Environment :: Console
+Provides: hello
+'''
+
+
class EggInfoToDistInfoTestCase(support.TempdirManager,
support.LoggingCatcher,
unittest.TestCase):
@@ -762,10 +797,14 @@ class EggInfoToDistInfoTestCase(support.TempdirManager,
dirs = [egginfo]
files = ['hello.py', 'hello.pyc']
extra_metadata = ['dependency_links.txt', 'entry_points.txt',
- 'not-zip-safe', 'PKG-INFO', 'top_level.txt',
- 'SOURCES.txt']
+ 'not-zip-safe', ('PKG-INFO', PKG_INFO),
+ 'top_level.txt', 'SOURCES.txt']
for f in extra_metadata:
- files.append(os.path.join(egginfo, f))
+ if isinstance(f, tuple):
+ f, content = f
+ else:
+ content = 'XXX'
+ files.append((os.path.join(egginfo, f), content))
tempdir, record_file = self.build_dist_tree(files, dirs)
distinfo_path = os.path.join(tempdir, distinfo)
@@ -784,7 +823,7 @@ class EggInfoToDistInfoTestCase(support.TempdirManager,
distinfo = 'hello-0.1.1-py3.3.dist-info'
egginfo = 'hello-0.1.1-py3.3.egg-info'
# egginfo is a file in distutils which contains the metadata
- files = ['hello.py', 'hello.pyc', egginfo]
+ files = ['hello.py', 'hello.pyc', (egginfo, PKG_INFO)]
tempdir, record_file = self.build_dist_tree(files, dirs=[])
distinfo_path = os.path.join(tempdir, distinfo)
@@ -792,6 +831,7 @@ class EggInfoToDistInfoTestCase(support.TempdirManager,
metadata_file_paths = self.get_metadata_file_paths(distinfo_path)
egginfo_to_distinfo(record_file)
+
# test that directories and files get created
self.assertTrue(os.path.isdir(distinfo_path))
self.assertTrue(os.path.isfile(egginfo_path))
@@ -808,9 +848,14 @@ class EggInfoToDistInfoTestCase(support.TempdirManager,
os.makedirs(path)
dir_paths.append(path)
for f in files:
+ if isinstance(f, (list, tuple)):
+ f, content = f
+ else:
+ content = ''
+
path = os.path.join(tempdir, f)
with open(path, 'w') as _f:
- _f.write(f)
+ _f.write(content)
file_paths.append(path)
with open(record_file_path, 'w') as record_file: