summaryrefslogtreecommitdiffstats
path: root/pym/portage/tests/dep/test_use_reduce.py
blob: 07b9ddbb9e8b282f6f8905f944cc6f4d2841a95e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Copyright 2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

from portage.tests import TestCase
from portage.exception import InvalidDependString
from portage.dep import paren_reduce, use_reduce
import portage.dep
portage.dep._dep_check_strict = True

class UseReduce(TestCase):

	def testUseReduce(self):

		tests = (
			('|| ( x y )',                                           True  ),
			('|| x',                                                 False ),
			('foo? ( x y )',                                         True  ),
			('foo? ( bar? x y )',                                    False ),
			('foo? x',                                               False ),
		)

		for dep_str, valid in tests:
			try:
				use_reduce(paren_reduce(dep_str), matchall=True)
			except InvalidDependString:
				self.assertEqual(valid, False)
			else:
				self.assertEqual(valid, True)