diff --git a/openstack_requirements/project.py b/openstack_requirements/project.py index 5471b86e77..378e268f2f 100644 --- a/openstack_requirements/project.py +++ b/openstack_requirements/project.py @@ -55,10 +55,12 @@ Verbose = collections.namedtuple('Verbose', ['message']) def extras(project): """Return a dict of extra-name:content for the extras in setup.cfg.""" + if 'setup.cfg' not in project: + return {} c = configparser.SafeConfigParser() c.readfp(io.StringIO(project['setup.cfg'])) if not c.has_section('extras'): - return dict() + return {} return dict(c.items('extras')) diff --git a/openstack_requirements/tests/test_project.py b/openstack_requirements/tests/test_project.py index ba1df5b360..a3739464f7 100644 --- a/openstack_requirements/tests/test_project.py +++ b/openstack_requirements/tests/test_project.py @@ -69,6 +69,10 @@ class TestProjectExtras(testtools.TestCase): proj = {'setup.cfg': u"[metadata]\n"} self.assertEqual({}, project.extras(proj)) + def test_no_setup_cfg(self): + proj = {} + self.assertEqual({}, project.extras(proj)) + class TestExtrasParsing(testtools.TestCase):