Fix test logic, tiny error / import cleanup

This commit is contained in:
Matthew Iversen 2014-02-19 10:31:12 +11:00
parent e0818e1240
commit 5a6855dcf1
3 changed files with 11 additions and 11 deletions

View File

@ -28,9 +28,7 @@ from pip.util import (
)
from pip.req.req_uninstall import UninstallPathSet
from pip.vcs import vcs
from pip.wheel import (
move_wheel_files, Wheel, wheel_ext, wheel_version
)
from pip.wheel import move_wheel_files, Wheel, wheel_ext
class InstallRequirement(object):
@ -712,7 +710,7 @@ exec(compile(
self.install_editable(install_options, global_options)
return
if self.is_wheel:
version = wheel_version(self.source_dir)
version = pip.wheel.wheel_version(self.source_dir)
pip.wheel.check_compatibility(version, self.name)
self.move_wheel_files(self.source_dir, root=root)

View File

@ -432,7 +432,7 @@ def check_compatibility(version, name):
"of pip" % (name, '.'.join(map(str, version)))
)
elif version > VERSION_COMPATIBLE:
logger.warn('Installing from a newer Wheel-Version: %s'
logger.warn('Installing from a newer Wheel-Version (%s)'
% '.'.join(map(str, version)))

View File

@ -63,9 +63,10 @@ def test_wheel_version(tmpdir, data):
def test_check_compatibility():
name = 'test'
higher_v = lower_v = wheel.VERSION_COMPATIBLE[:]
vc = wheel.VERSION_COMPATIBLE
higher_v = (higher_v[0] + 1, higher_v[1])
# Major version is higher - should be incompatible
higher_v = (vc[0] + 1, vc[1])
# test raises
with pytest.raises(UnsupportedWheel):
@ -77,14 +78,15 @@ def test_check_compatibility():
except UnsupportedWheel as e:
assert 'is not compatible' in str(e)
# Should only log.warn
wheel.check_compatibility((1, 9), name)
# Should only log.warn - minor version is greator
higher_v = (vc[0], vc[1] + 1)
wheel.check_compatibility(higher_v, name)
# These should work fine
wheel.check_compatibility(wheel.VERSION_COMPATIBLE, name)
lower_v = (lower_v[0], lower_v[1] - 1)
lower_v = wheel.VERSION_COMPATIBLE[:]
# E.g if wheel to install is 1.0 and we support up to 1.2
lower_v = (vc[0], max(0, vc[1] - 1))
wheel.check_compatibility(lower_v, name)