summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/portage/dep/__init__.py6
-rw-r--r--pym/portage/tests/dep/test_use_reduce.py20
2 files changed, 17 insertions, 9 deletions
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 010d88351..3db2ae02d 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -447,7 +447,11 @@ def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], i
# l = [[...]]
last = last_any_of_operator_level(level)
if last == -1:
- stack[level].extend(l[0])
+ if opconvert and isinstance(l[0], list) \
+ and l[0] and l[0][0] == '||':
+ stack[level].append(l[0])
+ else:
+ stack[level].extend(l[0])
else:
stack[level].append(l[0])
else:
diff --git a/pym/portage/tests/dep/test_use_reduce.py b/pym/portage/tests/dep/test_use_reduce.py
index 44f9fd710..f7e9b1012 100644
--- a/pym/portage/tests/dep/test_use_reduce.py
+++ b/pym/portage/tests/dep/test_use_reduce.py
@@ -317,12 +317,16 @@ class UseReduce(TestCase):
"A || ( B C )",
opconvert = True,
expected_result = ['A', ['||', 'B', 'C']]),
- # ['A', ['||', 'B', '||', 'C', 'D', 'E'], 'G'] != ['A', ['||', 'B', 'C', 'D', 'E'], 'G']
- #UseReduceTestCase(
- # "A foo? ( || ( B || ( bar? ( || ( C D E ) ) !bar? ( F ) ) ) ) G",
- # uselist = ["foo", "bar"],
- # opconvert = True,
- # expected_result = ['A', ['||', 'B', 'C', 'D', 'E'], 'G']),
+ UseReduceTestCase(
+ "A foo? ( || ( B || ( bar? ( || ( C D E ) ) !bar? ( F ) ) ) ) G",
+ uselist = ["foo", "bar"],
+ opconvert = True,
+ expected_result = ['A', ['||', 'B', ['||', 'C', 'D', 'E']], 'G']),
+ UseReduceTestCase(
+ "A foo? ( || ( B || ( bar? ( || ( C D E ) ) !bar? ( F ) ) ) ) G",
+ uselist = ["foo", "bar"],
+ opconvert = False,
+ expected_result = ['A', '||', ['B', 'C', 'D', 'E'], 'G']),
UseReduceTestCase(
"|| ( A )",
@@ -366,13 +370,13 @@ class UseReduce(TestCase):
"|| ( foo? ( || ( A B ) ) )",
uselist = ["foo"],
opconvert = True,
- expected_result = ["||", "A", "B"]),
+ expected_result = [['||', 'A', 'B']]),
UseReduceTestCase(
"|| ( ( A B ) foo? ( || ( C D ) ) )",
uselist = ["foo"],
opconvert = True,
- expected_result = [['||', ['A', 'B'], '||', 'C', 'D']]),
+ expected_result = [['||', ['A', 'B'], ['||', 'C', 'D']]]),
UseReduceTestCase(
"|| ( ( A B ) foo? ( || ( C D ) ) )",