Tolerate both new and old setuptools

New setuptools 20.2.2 seems to be throwing a new exception
as it uses a vendorized version of packaging now. Let's make
sure our tests works with both the older and newer versions.

Change-Id: Iab9247e2026896bb7d25b125788ec3072f819dad
This commit is contained in:
Davanum Srinivas 2016-02-28 14:48:27 -05:00
parent 9de6412851
commit 0cf3c06ad9

View File

@ -18,6 +18,11 @@ import testtools
from openstack_requirements import requirement
try:
InvalidRequirement = \
pkg_resources.extern.packaging.requirements.InvalidRequirement
except AttributeError:
InvalidRequirement = pkg_resources.RequirementParseError
load_tests = testscenarios.load_tests_apply_scenarios
@ -93,7 +98,7 @@ class TestParseRequirementFailures(testtools.TestCase):
('-f', dict(line='-f http://tarballs.openstack.org/'))]
def test_does_not_parse(self):
with testtools.ExpectedException(pkg_resources.RequirementParseError):
with testtools.ExpectedException(InvalidRequirement):
requirement.parse_line(self.line)
@ -134,7 +139,7 @@ class TestToReqs(testtools.TestCase):
self.assertEqual(reqs, [(req, line)])
def test_not_urls(self):
with testtools.ExpectedException(pkg_resources.RequirementParseError):
with testtools.ExpectedException(InvalidRequirement):
list(requirement.to_reqs('file:///foo#egg=foo'))
def test_multiline(self):