From 47fdbc13914e5a06a5acc69b3f3fec7eba91c48b Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Sat, 7 Nov 2015 22:53:34 -0500 Subject: [PATCH] Deal with underscores in blacklist during generate-constraints In change id I60adf0dca4aa32f4ef6bca61250b375c8a3703c6, we added flake8_docstrings to the black list. However as seen in I8bfff1b2e65541959e7f2ae0fa6ca6c17889eb54, the generate-constraints job ends up proposing adding "flake8-docstrings===0.2.1.post1" to the upper-constraints.txt. This is because of the '-' vs '_' difference. So just like in Ibaa22657a2cf2c0ad96dbd0b9bc43cdafe6a1d56, we need to convert the items in black list to the correct safe name before trying to check if the item is in the black list. Change-Id: Ieb1cd44e908b80d58a20bf0d0e1e6b10f17ae95e --- openstack_requirements/cmds/generate.py | 5 ++++- openstack_requirements/tests/test_generate.py | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/openstack_requirements/cmds/generate.py b/openstack_requirements/cmds/generate.py index 20d5dfd1e0..1bfbdeb20b 100644 --- a/openstack_requirements/cmds/generate.py +++ b/openstack_requirements/cmds/generate.py @@ -18,6 +18,8 @@ import sys import fixtures +from openstack_requirements import requirement + def _parse_freeze(text): """Parse a freeze into structured data. @@ -100,7 +102,8 @@ def _combine_freezes(freezes, blacklist=None): :return: A list of '\n' terminated lines for a requirements file. """ packages = {} # {package : {version : [py_version]}} - excludes = frozenset((s.lower() for s in blacklist) if blacklist else ()) + excludes = frozenset((requirement.canonical_name(s) + for s in blacklist) if blacklist else ()) reference_versions = [] for py_version, freeze in freezes: if py_version in reference_versions: diff --git a/openstack_requirements/tests/test_generate.py b/openstack_requirements/tests/test_generate.py index d6c7be39c0..8cf7a15d3e 100644 --- a/openstack_requirements/tests/test_generate.py +++ b/openstack_requirements/tests/test_generate.py @@ -89,3 +89,12 @@ class TestCombine(testtools.TestCase): ["enum===1.5.0;python_version=='3.4'\n"], list(generate._combine_freezes( [freeze_27, freeze_34], blacklist=blacklist))) + + def test_blacklist_with_safe_name(self): + blacklist = ['flake8_docstrings'] + freeze_27 = ('2.7', [('flake8-docstrings', '0.2.1.post1'), + ('enum', '1.5.0')]) + self.assertEqual( + ['enum===1.5.0\n'], + list(generate._combine_freezes( + [freeze_27], blacklist=blacklist)))