Improve version test (use pkg_resources to compare versions). Also log failures to stderr.

--HG--
branch : pytest-2.7
This commit is contained in:
Ionel Cristian Maries 2015-04-10 21:44:27 +03:00
parent b7d43c5a5d
commit 40a682476d
1 changed files with 4 additions and 2 deletions

View File

@ -29,8 +29,10 @@ def get_version():
def has_newish_setuptools():
try:
import setuptools
return tuple(int(i) for i in str(setuptools.__version__).split('.')) > (0, 7)
except Exception:
import pkg_resources
return pkg_resources.parse_version(setuptools.__version__) >= pkg_resources.parse_version('0.7')
except Exception as exc:
sys.stderr.write("Could not test setuptool's version: %s\n" % exc)
return False