summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Holth <dholth@fastmail.fm>2013-06-23 13:25:56 -0400
committerDaniel Holth <dholth@fastmail.fm>2013-06-23 13:25:56 -0400
commitf6f3e67fb5d3c1f922dcf8b08f04908fd2086c6f (patch)
tree387a47f5127d27040cce1b7265a80f48c87ab575
parentbad4114e921814c1cbf89296b003bbef4b46cd5b (diff)
downloadwheel-f6f3e67fb5d3c1f922dcf8b08f04908fd2086c6f.tar.gz
use pytest for tests
-rw-r--r--setup.cfg10
-rw-r--r--setup.py3
-rw-r--r--wheel/bdist_wheel.py64
-rw-r--r--wheel/test/__init__.py125
-rw-r--r--wheel/test/test_basic.py140
-rw-r--r--wheel/test/test_wheelfile.py4
6 files changed, 179 insertions, 167 deletions
diff --git a/setup.cfg b/setup.cfg
index dff1384..bdd2dcb 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,10 +1,6 @@
-[nosetests]
-where=wheel/test
-cover-package=wheel
-nocapture=1
-with-coverage=1
-cover-erase=1
-with-doctest=1
+[pytest]
+cov=wheel
+addopts=--ignore=dist --ignore=build
[metadata]
provides-extra =
diff --git a/setup.py b/setup.py
index 757e95f..1c05996 100644
--- a/setup.py
+++ b/setup.py
@@ -49,10 +49,9 @@ setup(name='wheel',
'faster-signatures': ['ed25519ll'],
'tool': []
},
- tests_require=['jsonschema'],
+ tests_require=['jsonschema', 'py.test', 'coverage', 'pytest-cov'],
include_package_data=True,
zip_safe=False,
- test_suite = 'nose.collector',
entry_points = """\
[console_scripts]
wininst2wheel = wheel.wininst2wheel:main
diff --git a/wheel/bdist_wheel.py b/wheel/bdist_wheel.py
index a0d3b91..4befac3 100644
--- a/wheel/bdist_wheel.py
+++ b/wheel/bdist_wheel.py
@@ -209,36 +209,6 @@ class bdist_wheel(Command):
self.egg2dist(self.egginfo_dir,
self.distinfo_dir)
- # XXX deprecated.
- metadata_path = os.path.join(self.distinfo_dir, 'METADATA')
- self.add_requirements(metadata_path)
-
- # XXX not a final specification
- metadata_json_path = os.path.join(self.distinfo_dir, 'pymeta.json')
- pymeta = pkginfo_to_dict(metadata_path,
- distribution=self.distribution)
-
- if 'description' in pymeta:
- description_filename = 'DESCRIPTION.rst'
- description_text = pymeta.pop('description')
- description_path = os.path.join(self.distinfo_dir,
- description_filename)
- with open(description_path, "wb") as description_file:
- description_file.write(description_text.encode('utf-8'))
- pymeta['document_names'] = pymeta.get('document_names', {})
- pymeta['document_names']['description'] = description_filename
-
- # XXX heuristically copy any LICENSE/LICENSE.txt?
- license = self.license_file()
- if license:
- license_filename = 'LICENSE.txt'
- shutil.copy(license, os.path.join(self.distinfo_dir, license_filename))
- pymeta['document_names'] = pymeta.get('document_names', {})
- pymeta['document_names']['license'] = license_filename
-
- with open(metadata_json_path, "w") as metadata_json:
- json.dump(pymeta, metadata_json)
-
self.write_wheelfile(self.distinfo_dir)
self.write_record(self.bdist_dir, self.distinfo_dir)
@@ -394,6 +364,36 @@ class bdist_wheel(Command):
adios(dependency_links)
write_pkg_info(os.path.join(distinfo_path, 'METADATA'), pkg_info)
+
+ # XXX deprecated. Still useful for current distribute/setuptools.
+ metadata_path = os.path.join(distinfo_path, 'METADATA')
+ self.add_requirements(metadata_path)
+
+ # XXX not a final specification
+ metadata_json_path = os.path.join(distinfo_path, 'pymeta.json')
+ pymeta = pkginfo_to_dict(metadata_path,
+ distribution=self.distribution)
+
+ if 'description' in pymeta:
+ description_filename = 'DESCRIPTION.rst'
+ description_text = pymeta.pop('description')
+ description_path = os.path.join(distinfo_path,
+ description_filename)
+ with open(description_path, "wb") as description_file:
+ description_file.write(description_text.encode('utf-8'))
+ pymeta['document_names'] = pymeta.get('document_names', {})
+ pymeta['document_names']['description'] = description_filename
+
+ # XXX heuristically copy any LICENSE/LICENSE.txt?
+ license = self.license_file()
+ if license:
+ license_filename = 'LICENSE.txt'
+ shutil.copy(license, os.path.join(self.distinfo_dir, license_filename))
+ pymeta['document_names'] = pymeta.get('document_names', {})
+ pymeta['document_names']['license'] = license_filename
+
+ with open(metadata_json_path, "w") as metadata_json:
+ json.dump(pymeta, metadata_json)
adios(egginfo_path)
@@ -409,8 +409,8 @@ class bdist_wheel(Command):
yield os.path.join(dir, f)
def skip(path):
- return (path.endswith('.pyc')
- or path.endswith('.pyo') or path == record_relpath)
+ """Wheel hashes every possible file."""
+ return (path == record_relpath)
with open_for_csv(record_path, 'w+') as record_file:
writer = csv.writer(record_file)
diff --git a/wheel/test/__init__.py b/wheel/test/__init__.py
index 3ee5657..4287ca8 100644
--- a/wheel/test/__init__.py
+++ b/wheel/test/__init__.py
@@ -1,124 +1 @@
-import os
-import distutils
-import pkg_resources
-import json
-import sys
-
-from pkg_resources import resource_filename
-
-from nose.tools import assert_true, assert_false, assert_equal, raises
-
-import wheel.util
-from wheel import egg2wheel
-from wheel.install import WheelFile
-from zipfile import ZipFile
-
-
-def test_findable():
- """Make sure pkg_resources can find us."""
- assert pkg_resources.working_set.by_key['wheel'].version
-
-
-def test_egg_re():
- """Make sure egg_info_re matches."""
- egg_names = open(pkg_resources.resource_filename('wheel', 'eggnames.txt'))
- for line in egg_names:
- line = line.strip()
- if not line:
- continue
- assert egg2wheel.egg_info_re.match(line), line
-
-
-def test_compatibility_tags():
- """Test compatibilty tags are working."""
- wf = WheelFile("package-1.0.0-cp32.cp33-noabi-noarch.whl")
- assert_equal(list(wf.compatibility_tags),
- [('cp32', 'noabi', 'noarch'), ('cp33', 'noabi', 'noarch')])
- assert_equal(wf.arity, 2)
-
- wf2 = WheelFile("package-1.0.0-1st-cp33-noabi-noarch.whl")
- wf2_info = wf2.parsed_filename.groupdict()
- assert wf2_info['build'] == '1st', wf2_info
-
-
-def test_bdist_wheel():
- """Make sure bdist_wheel finish without errors."""
- for dist in ("simple.dist", "complex-dist"):
- pwd = os.curdir
- simpledist = pkg_resources.resource_filename('wheel.test', dist)
- os.chdir(simpledist)
- try:
- sys.argv = ['', 'bdist_wheel']
- exec(compile(open('setup.py').read(), 'setup.py', 'exec'))
- finally:
- os.chdir(pwd)
-
-def test_pymeta():
- """Make sure pymeta.json exists and validates against our schema."""
- # XXX this test may need manual cleanup of older wheels
-
- import jsonschema
-
- def open_json(filename):
- return json.loads(open(filename, 'rb').read().decode('utf-8'))
-
- pymeta_schema = open_json(resource_filename('wheel.test',
- 'pymeta-schema.json'))
- valid = 0
- for dist in ("simple.dist", "complex-dist"):
- basedir = pkg_resources.resource_filename('wheel.test', dist)
- for (dirname, subdirs, filenames) in os.walk(basedir):
- for filename in filenames:
- if filename.endswith('.whl'):
- whl = ZipFile(os.path.join(dirname, filename))
- for entry in whl.infolist():
- if entry.filename.endswith('/pymeta.json'):
- pymeta = json.loads(whl.read(entry).decode('utf-8'))
- jsonschema.validate(pymeta, pymeta_schema)
- valid += 1
- assert valid > 0, "No pymeta.json found"
-
-def test_util():
- """Test functions in util.py."""
- for i in range(10):
- before = b'*' * i
- encoded = wheel.util.urlsafe_b64encode(before)
- assert not encoded.endswith(b'=')
- after = wheel.util.urlsafe_b64decode(encoded)
- assert before == after
-
-
-def test_pick_best():
- """Test the wheel ranking algorithm."""
- def get_tags(res):
- info = res[-1].parsed_filename.groupdict()
- return info['pyver'], info['abi'], info['plat']
-
- cand_tags = [('py27', 'noabi', 'noarch'), ('py26', 'noabi', 'noarch'),
- ('cp27', 'noabi', 'linux_i686'),
- ('cp26', 'noabi', 'linux_i686'),
- ('cp27', 'noabi', 'linux_x86_64'),
- ('cp26', 'noabi', 'linux_x86_64')]
- cand_wheels = [WheelFile('testpkg-1.0-%s-%s-%s.whl' % t)
- for t in cand_tags]
-
- supported = [('cp27', 'noabi', 'linux_i686'), ('py27', 'noabi', 'noarch')]
- supported2 = [('cp27', 'noabi', 'linux_i686'), ('py27', 'noabi', 'noarch'),
- ('cp26', 'noabi', 'linux_i686'), ('py26', 'noabi', 'noarch')]
- supported3 = [('cp26', 'noabi', 'linux_i686'), ('py26', 'noabi', 'noarch'),
- ('cp27', 'noabi', 'linux_i686'), ('py27', 'noabi', 'noarch')]
-
- for supp in (supported, supported2, supported3):
- context = lambda: list(supp)
- for wheel in cand_wheels:
- wheel.context = context
- best = max(cand_wheels)
- assert_equal(list(best.tags)[0], supp[0])
-
- # assert_equal(
- # list(map(get_tags, pick_best(cand_wheels, supp, top=False))), supp)
-
-
-if __name__ == '__main__':
- import nose
- nose.main()
+# \ No newline at end of file
diff --git a/wheel/test/test_basic.py b/wheel/test/test_basic.py
new file mode 100644
index 0000000..9961074
--- /dev/null
+++ b/wheel/test/test_basic.py
@@ -0,0 +1,140 @@
+"""
+Basic wheel tests.
+"""
+
+import os
+import pkg_resources
+import json
+import sys
+
+from pkg_resources import resource_filename
+
+import wheel.util
+from wheel import egg2wheel
+from wheel.install import WheelFile
+from zipfile import ZipFile
+from shutil import rmtree
+
+test_distributions = ("simple.dist", "complex-dist", "headers.dist")
+
+def teardown_module():
+ """Delete eggs/wheels created by tests."""
+ for dist in test_distributions:
+ rmtree(pkg_resources.resource_filename('wheel.test',
+ os.path.join(dist, 'build')))
+
+def test_findable():
+ """Make sure pkg_resources can find us."""
+ assert pkg_resources.working_set.by_key['wheel'].version
+
+
+def test_egg_re():
+ """Make sure egg_info_re matches."""
+ egg_names = open(pkg_resources.resource_filename('wheel', 'eggnames.txt'))
+ for line in egg_names:
+ line = line.strip()
+ if not line:
+ continue
+ assert egg2wheel.egg_info_re.match(line), line
+
+
+def test_compatibility_tags():
+ """Test compatibilty tags are working."""
+ wf = WheelFile("package-1.0.0-cp32.cp33-noabi-noarch.whl")
+ assert (list(wf.compatibility_tags) ==
+ [('cp32', 'noabi', 'noarch'), ('cp33', 'noabi', 'noarch')])
+ assert (wf.arity == 2)
+
+ wf2 = WheelFile("package-1.0.0-1st-cp33-noabi-noarch.whl")
+ wf2_info = wf2.parsed_filename.groupdict()
+ assert wf2_info['build'] == '1st', wf2_info
+
+
+def test_bdist_wheel():
+ """Make sure bdist_wheel finish without errors."""
+ for dist in test_distributions:
+ pwd = os.curdir
+ simpledist = pkg_resources.resource_filename('wheel.test', dist)
+ os.chdir(simpledist)
+ try:
+ sys.argv = ['', 'bdist_wheel']
+ exec(compile(open('setup.py').read(), 'setup.py', 'exec'))
+ finally:
+ os.chdir(pwd)
+
+def test_convert_egg():
+ """Convert some eggs to wheels."""
+ for dist in ("simple.dist", "complex-dist", "headers.dist"):
+ pwd = os.curdir
+ simpledist = pkg_resources.resource_filename('wheel.test', dist)
+ os.chdir(simpledist)
+ try:
+ sys.argv = ['', 'bdist_egg']
+ exec(compile(open('setup.py').read(), 'setup.py', 'exec'))
+ finally:
+ os.chdir(pwd)
+
+def test_pymeta():
+ """Make sure pymeta.json exists and validates against our schema."""
+ # XXX this test may need manual cleanup of older wheels
+
+ import jsonschema
+
+ def open_json(filename):
+ return json.loads(open(filename, 'rb').read().decode('utf-8'))
+
+ pymeta_schema = open_json(resource_filename('wheel.test',
+ 'pymeta-schema.json'))
+ valid = 0
+ for dist in ("simple.dist", "complex-dist"):
+ basedir = pkg_resources.resource_filename('wheel.test', dist)
+ for (dirname, subdirs, filenames) in os.walk(basedir):
+ for filename in filenames:
+ if filename.endswith('.whl'):
+ whl = ZipFile(os.path.join(dirname, filename))
+ for entry in whl.infolist():
+ if entry.filename.endswith('/pymeta.json'):
+ pymeta = json.loads(whl.read(entry).decode('utf-8'))
+ jsonschema.validate(pymeta, pymeta_schema)
+ valid += 1
+ assert valid > 0, "No pymeta.json found"
+
+def test_util():
+ """Test functions in util.py."""
+ for i in range(10):
+ before = b'*' * i
+ encoded = wheel.util.urlsafe_b64encode(before)
+ assert not encoded.endswith(b'=')
+ after = wheel.util.urlsafe_b64decode(encoded)
+ assert before == after
+
+
+def test_pick_best():
+ """Test the wheel ranking algorithm."""
+ def get_tags(res):
+ info = res[-1].parsed_filename.groupdict()
+ return info['pyver'], info['abi'], info['plat']
+
+ cand_tags = [('py27', 'noabi', 'noarch'), ('py26', 'noabi', 'noarch'),
+ ('cp27', 'noabi', 'linux_i686'),
+ ('cp26', 'noabi', 'linux_i686'),
+ ('cp27', 'noabi', 'linux_x86_64'),
+ ('cp26', 'noabi', 'linux_x86_64')]
+ cand_wheels = [WheelFile('testpkg-1.0-%s-%s-%s.whl' % t)
+ for t in cand_tags]
+
+ supported = [('cp27', 'noabi', 'linux_i686'), ('py27', 'noabi', 'noarch')]
+ supported2 = [('cp27', 'noabi', 'linux_i686'), ('py27', 'noabi', 'noarch'),
+ ('cp26', 'noabi', 'linux_i686'), ('py26', 'noabi', 'noarch')]
+ supported3 = [('cp26', 'noabi', 'linux_i686'), ('py26', 'noabi', 'noarch'),
+ ('cp27', 'noabi', 'linux_i686'), ('py27', 'noabi', 'noarch')]
+
+ for supp in (supported, supported2, supported3):
+ context = lambda: list(supp)
+ for wheel in cand_wheels:
+ wheel.context = context
+ best = max(cand_wheels)
+ assert list(best.tags)[0] == supp[0]
+
+ # assert_equal(
+ # list(map(get_tags, pick_best(cand_wheels, supp, top=False))), supp)
diff --git a/wheel/test/test_wheelfile.py b/wheel/test/test_wheelfile.py
index efbbbda..e362ceb 100644
--- a/wheel/test/test_wheelfile.py
+++ b/wheel/test/test_wheelfile.py
@@ -5,11 +5,11 @@ try:
except ImportError:
from io import BytesIO as StringIO
import zipfile
-from nose import SkipTest
+import pytest
def test_verifying_zipfile():
if not hasattr(zipfile.ZipExtFile, '_update_crc'):
- raise SkipTest('No ZIP verification. Missing ZipExtFile._update_crc.')
+ pytest.skip('No ZIP verification. Missing ZipExtFile._update_crc.')
sio = StringIO()
zf = zipfile.ZipFile(sio, 'w')