stack = [[]]
need_bracket = False
affecting_use = set()
- atom_seen = False
def flag(conditional):
if conditional[0] == "!":
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
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):
("( 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 = (
("a? A", "A"),
("( || ( || || ( A ) foo? ( B ) ) )", "A"),
("( || ( || bar? ( A ) foo? ( B ) ) )", "A"),
-
- ("a? ( A )", "B"),
)
for dep, atom, expected in test_cases:
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)