Add tests for use_reduce() and paren_reduce().
authorZac Medico <zmedico@gentoo.org>
Thu, 5 Mar 2009 05:21:36 +0000 (05:21 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 5 Mar 2009 05:21:36 +0000 (05:21 -0000)
svn path=/main/trunk/; revision=12759

pym/portage/tests/dep/test_use_reduce.py [new file with mode: 0644]

diff --git a/pym/portage/tests/dep/test_use_reduce.py b/pym/portage/tests/dep/test_use_reduce.py
new file mode 100644 (file)
index 0000000..07b9ddb
--- /dev/null
@@ -0,0 +1,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)