From 0cf3c06ad98fa86378ffd561b65c0154989b179c Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Sun, 28 Feb 2016 14:48:27 -0500 Subject: [PATCH] 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 --- openstack_requirements/tests/test_requirement.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openstack_requirements/tests/test_requirement.py b/openstack_requirements/tests/test_requirement.py index 71f821e3be..57f62ced18 100644 --- a/openstack_requirements/tests/test_requirement.py +++ b/openstack_requirements/tests/test_requirement.py @@ -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):