diff options
author | Sebastian Luther <SebastianLuther@gmx.de> | 2010-08-10 08:41:10 +0200 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-08-10 00:02:11 -0700 |
commit | 8e7a2082f726b64f3742266148b89e7cb4101ee4 (patch) | |
tree | 1c292c72217c6df8272ee845d11d322a72b4e272 /pym/portage/tests/dep/test_paren_reduce.py | |
parent | 77c2db9850be29d1cd94c58cbc2e2b05e03bc9d2 (diff) | |
download | portage-8e7a2082f726b64f3742266148b89e7cb4101ee4.tar.gz portage-8e7a2082f726b64f3742266148b89e7cb4101ee4.tar.bz2 portage-8e7a2082f726b64f3742266148b89e7cb4101ee4.zip |
portage.dep: Rewrite paren_reduce and add tests
Diffstat (limited to 'pym/portage/tests/dep/test_paren_reduce.py')
-rw-r--r-- | pym/portage/tests/dep/test_paren_reduce.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/pym/portage/tests/dep/test_paren_reduce.py b/pym/portage/tests/dep/test_paren_reduce.py new file mode 100644 index 000000000..3277ab58b --- /dev/null +++ b/pym/portage/tests/dep/test_paren_reduce.py @@ -0,0 +1,46 @@ +# Copyright 2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +from portage.tests import TestCase +from portage.dep import paren_reduce +from portage.exception import InvalidDependString + +class TestParenReduce(TestCase): + + def testParenReduce(self): + + test_cases = ( + ( "A", ["A"]), + ( "( A )", [["A"]]), + ( "|| ( A B )", [ "||", ["A", "B"] ]), + ( "|| ( A || ( B C ) )", [ "||", ["A", "||", ["B", "C"]]]), + ( "|| ( A || ( B C D ) )", [ "||", ["A", "||", ["B", "C", "D"]] ]), + ( "|| ( A || ( B || ( C D ) E ) )", [ "||", ["A", "||", ["B", "||", ["C", "D"], "E"]] ]), + ( "a? ( A )", ["a?", ["A"]]), + ) + + test_cases_xfail = ( + "( A", + "A )", + + "||( A B )", + "|| (A B )", + "|| ( A B)", + "|| ( A B", + "|| A B )", + + "|| A B", + "|| ( A B ) )", + "|| || B C", + + "|| ( A B || )", + + "a? A", + ) + + for dep_str, expected_result in test_cases: + self.assertEqual(paren_reduce(dep_str), expected_result) + + for dep_str in test_cases_xfail: + self.assertRaisesMsg(dep_str, + InvalidDependString, paren_reduce, dep_str) |