portage.dep.extract_affecting_use: Don't raise if atom is not in dep string
authorSebastian Luther <SebastianLuther@gmx.de>
Thu, 12 Aug 2010 10:30:20 +0000 (12:30 +0200)
committerZac Medico <zmedico@gentoo.org>
Thu, 12 Aug 2010 10:40:45 +0000 (03:40 -0700)
pym/portage/dep/__init__.py
pym/portage/tests/dep/testExtractAffectingUSE.py

index f15b8a2d95abdb7ebed487f739b5d825264e3c0b..4c15b787cb3121f55f9e07a9d9a678376cb19df2 100644 (file)
@@ -1481,7 +1481,6 @@ def extract_affecting_use(mystr, atom):
        stack = [[]]
        need_bracket = False
        affecting_use = set()
-       atom_seen = False
 
        def flag(conditional):
                if conditional[0] == "!":
@@ -1549,15 +1548,10 @@ def extract_affecting_use(mystr, atom):
                                need_bracket = True
                                stack[level].append(token)
                        elif token == atom:
-                               atom_seen = True
                                stack[level].append(token)
 
        if level != 0 or need_bracket:
                raise portage.exception.InvalidDependString(
                        _("malformed syntax: '%s'") % mystr)
 
-       if not atom_seen:
-               raise portage.exception.IncorrectParameter(
-                       _("extract_affecting_use: atom '%s' not in dep string: '%s'") % (atom, mystr))
-
        return affecting_use
index ba904b9274c413222fcaa63d840b39d021d987c4..79ac9fc73d77c9f6eb68b3e4ffbdef8bf8e9273c 100644 (file)
@@ -3,7 +3,7 @@
 
 from portage.tests import TestCase
 from portage.dep import extract_affecting_use
-from portage.exception import InvalidDependString, IncorrectParameter
+from portage.exception import InvalidDependString
 
 class TestExtractAffectingUSE(TestCase):
 
@@ -32,6 +32,8 @@ class TestExtractAffectingUSE(TestCase):
                        ("( ab? ( || ( ( A ) || ( b? ( ( ( || ( B ( C ) ) ) ) ) ) ) ) )", "A", ("ab",)),
                        ("( ab? ( || ( ( A ) || ( b? ( ( ( || ( B ( C ) ) ) ) ) ) ) ) )", "B", ("ab", "b")),
                        ("( ab? ( || ( ( A ) || ( b? ( ( ( || ( B ( C ) ) ) ) ) ) ) ) )", "C", ("ab", "b")),
+
+                       ("a? ( A )", "B", []),
                )
 
                test_cases_xfail = (
@@ -52,8 +54,6 @@ class TestExtractAffectingUSE(TestCase):
                        ("a? A", "A"),
                        ("( || ( || || ( A ) foo? ( B ) ) )", "A"),
                        ("( || ( || bar? ( A ) foo? ( B ) ) )", "A"),
-
-                       ("a? ( A )", "B"),
                )
 
                for dep, atom, expected in test_cases:
@@ -67,4 +67,4 @@ class TestExtractAffectingUSE(TestCase):
                        fail_msg = "dep: " + dep + ", atom: " + atom + ", got: " + \
                                " ".join(sorted(result)) + ", expected: " + " ".join(sorted(expected))
                        self.assertRaisesMsg(fail_msg, \
-                               (InvalidDependString, IncorrectParameter), extract_affecting_use, dep, atom)
+                               InvalidDependString, extract_affecting_use, dep, atom)