From 83b781ae4f4c27c2857439bb02a8c2009a4ee87d Mon Sep 17 00:00:00 2001 From: Jens Harbott Date: Thu, 9 Jul 2020 13:43:53 +0000 Subject: [PATCH] Fix failure with setuptools >= 49.0.0 Recent setuptools include updated vendored pkg_resource that changed the exception that we need to expect from them. Leave in the old version, too, for backwards compatibility. Change-Id: I5bb01fb21982fb8757e925659ad206a15a79f799 --- openstack_requirements/tests/test_requirement.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/openstack_requirements/tests/test_requirement.py b/openstack_requirements/tests/test_requirement.py index 7a5bb99c1a..53bc01ab9a 100644 --- a/openstack_requirements/tests/test_requirement.py +++ b/openstack_requirements/tests/test_requirement.py @@ -13,6 +13,7 @@ import textwrap import pkg_resources +import pkg_resources.extern.packaging.requirements as pkg_resources_reqs import testscenarios import testtools @@ -106,8 +107,13 @@ class TestParseRequirementFailures(testtools.TestCase): ('-f', dict(line='-f http://tarballs.openstack.org/'))] def test_does_not_parse(self): - with testtools.ExpectedException(pkg_resources.RequirementParseError): + try: requirement.parse_line(self.line) + except (pkg_resources.RequirementParseError, + pkg_resources_reqs.InvalidRequirement): + pass + else: + self.fail('No exception triggered') class TestToContent(testtools.TestCase): @@ -147,8 +153,13 @@ class TestToReqs(testtools.TestCase): self.assertEqual(reqs, [(req, line)]) def test_not_urls(self): - with testtools.ExpectedException(pkg_resources.RequirementParseError): + try: list(requirement.to_reqs('file:///foo#egg=foo')) + except (pkg_resources.RequirementParseError, + pkg_resources_reqs.InvalidRequirement): + pass + else: + self.fail('No exception triggered') def test_multiline(self): content = textwrap.dedent("""\