Skip to content

Commit

Permalink
Renamed the wheel.tool package to wheel.cli and migrated CLI stuff there
Browse files Browse the repository at this point in the history
The VerifyingZipFile class was also merged to the WheelFile class.
  • Loading branch information
agronholm committed Jul 17, 2018
1 parent 353217f commit 8949250
Show file tree
Hide file tree
Showing 37 changed files with 665 additions and 1,072 deletions.
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -50,7 +50,7 @@
zip_safe=False,
entry_points={
'console_scripts': [
'wheel=wheel.tool:main'
'wheel=wheel.cli:main'
],
'distutils.commands': [
'bdist_wheel=wheel.bdist_wheel:bdist_wheel'
Expand Down
File renamed without changes.
9 changes: 7 additions & 2 deletions tests/test_egg2wheel.py → tests/cli/test_convert.py
@@ -1,6 +1,6 @@
import os.path

from wheel import egg2wheel
from wheel.cli.convert import convert, egg_info_re


def test_egg_re():
Expand All @@ -10,4 +10,9 @@ def test_egg_re():
for line in egg_names:
line = line.strip()
if line:
assert egg2wheel.egg_info_re.match(line), line
assert egg_info_re.match(line), line


def test_convert_egg(egg_paths, tmpdir):
convert(egg_paths, str(tmpdir), verbose=False)
assert len(tmpdir.listdir()) == len(egg_paths)
File renamed without changes.
10 changes: 10 additions & 0 deletions tests/cli/test_unpack.py
@@ -0,0 +1,10 @@
from wheel.cli.unpack import unpack


def test_unpack(wheel_paths, tmpdir):
"""
Make sure 'wheel unpack' works.
This also verifies the integrity of our testing wheel files.
"""
for wheel_path in wheel_paths:
unpack(wheel_path, str(tmpdir))
47 changes: 3 additions & 44 deletions tests/conftest.py
Expand Up @@ -2,54 +2,12 @@
pytest local configuration plug-in
"""

import gc
import os.path
import subprocess
import sys
from shutil import rmtree

import pytest
import warnings

THISDIR = os.path.dirname(__file__)


@pytest.fixture(autouse=True)
def error_on_ResourceWarning():
"""This fixture captures ResourceWarning's and reports an "error"
describing the file handles left open.
This is shown regardless of how successful the test was, if a test fails
and leaves files open then those files will be reported. Ideally, even
those files should be closed properly after a test failure or exception.
Since only Python 3 and PyPy3 have ResourceWarning's, this context will
have no effect when running tests on Python 2 or PyPy.
Because of autouse=True, this function will be automatically enabled for
all test_* functions in this module.
This code is primarily based on the examples found here:
https://stackoverflow.com/questions/24717027/convert-python-3-resourcewarnings-into-exception
"""
try:
ResourceWarning
except NameError:
# Python 2, PyPy
yield
return

# Python 3, PyPy3
with warnings.catch_warnings(record=True) as caught:
warnings.resetwarnings() # clear all filters
warnings.simplefilter('ignore') # ignore all
warnings.simplefilter('always', ResourceWarning) # noqa: F821
yield # run tests in this context
gc.collect() # run garbage collection (for pypy3)
if caught:
pytest.fail('The following file descriptors were not closed properly:\n' +
'\n'.join((str(warning.message) for warning in caught)),
pytrace=False)


@pytest.fixture(scope='session')
Expand All @@ -58,8 +16,9 @@ def wheels_and_eggs():
test_distributions = "complex-dist", "simple.dist", "headers.dist", "unicode.dist"
files = []
pwd = os.path.abspath(os.curdir)
this_dir = os.path.dirname(__file__)
for dist in test_distributions:
os.chdir(os.path.join(THISDIR, dist))
os.chdir(os.path.join(this_dir, 'testdata', dist))
subprocess.check_call([sys.executable, 'setup.py', 'bdist_egg', 'bdist_wheel'])
dist_path = os.path.join(os.curdir, 'dist')
files.extend([os.path.abspath(os.path.join(dist_path, fname))
Expand All @@ -72,7 +31,7 @@ def wheels_and_eggs():
for dist in test_distributions:
for subdir in ('build', 'dist'):
try:
rmtree(os.path.join(THISDIR, dist, subdir))
rmtree(os.path.join(this_dir, dist, subdir))
except OSError:
pass

Expand Down
71 changes: 0 additions & 71 deletions tests/test_install.py

This file was deleted.

43 changes: 0 additions & 43 deletions tests/test_ranking.py

This file was deleted.

15 changes: 0 additions & 15 deletions tests/test_tool.py

This file was deleted.

0 comments on commit 8949250

Please sign in to comment.