summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/portage/dep/__init__.py7
-rw-r--r--pym/portage/tests/dep/testCheckRequiredUse.py32
2 files changed, 36 insertions, 3 deletions
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 7e9a18ad3..0300b7489 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -2088,11 +2088,14 @@ class _RequiredUseBranch(object):
def tounicode(self):
+ include_parens = self._parent is not None and \
+ (self._operator is not None or \
+ self._parent._operator is None)
tokens = []
if self._operator is not None:
tokens.append(self._operator)
- if self._parent is not None:
+ if include_parens:
tokens.append("(")
complex_nesting = False
@@ -2111,7 +2114,7 @@ class _RequiredUseBranch(object):
if not child._satisfied:
tokens.append(child.tounicode())
- if self._parent is not None:
+ if include_parens:
tokens.append(")")
return " ".join(tokens)
diff --git a/pym/portage/tests/dep/testCheckRequiredUse.py b/pym/portage/tests/dep/testCheckRequiredUse.py
index 0f7a299e9..0fb97023a 100644
--- a/pym/portage/tests/dep/testCheckRequiredUse.py
+++ b/pym/portage/tests/dep/testCheckRequiredUse.py
@@ -134,7 +134,37 @@ class TestCheckRequiredUse(TestCase):
(
"^^ ( || ( ( a b ) ) ( c ) )",
("a", "b", "c"),
- "^^ ( || ( ( a b ) ) ( c ) )"
+ "^^ ( || ( a b ) c )"
+ ),
+ (
+ "a? ( ( c e ) ( b d ) )",
+ ("a", "c", "e"),
+ "a? ( b d )"
+ ),
+ (
+ "a? ( ( c e ) ( b d ) )",
+ ("a", "b", "c", "e"),
+ "a? ( d )"
+ ),
+ (
+ "^^ ( || ( a b ) ^^ ( b c ) )",
+ ("a", "b"),
+ "^^ ( || ( a b ) ^^ ( b c ) )"
+ ),
+ (
+ "^^ ( || ( a b ) ^^ ( b c ) )",
+ ["a", "c"],
+ "^^ ( || ( a b ) ^^ ( b c ) )"
+ ),
+ (
+ "^^ ( || ( a b ) ^^ ( b c ) )",
+ ["b", "c"],
+ ""
+ ),
+ (
+ "^^ ( || ( a b ) ^^ ( b c ) )",
+ ["a", "b", "c"],
+ ""
)
)
for required_use, use, expected in test_cases: