summaryrefslogtreecommitdiff
path: root/pym
diff options
context:
space:
mode:
authorSebastian Luther <SebastianLuther@gmx.de>2010-08-08 21:55:51 +0200
committerZac Medico <zmedico@gentoo.org>2010-08-08 17:34:54 -0700
commit2b37a784ac960d8a0ebe77cba37c1e8ca9f10c54 (patch)
tree499b65fb7236b4db45c59a7c66a30cddcb063795 /pym
parentportage.dep.Atom.violated_conditionals(): Fix "not / is None" bug (diff)
downloadportage-multirepo-2b37a784ac960d8a0ebe77cba37c1e8ca9f10c54.tar.gz
portage-multirepo-2b37a784ac960d8a0ebe77cba37c1e8ca9f10c54.tar.bz2
portage-multirepo-2b37a784ac960d8a0ebe77cba37c1e8ca9f10c54.zip
Tests: dep/testAtom: add test for Atom.violated_conditionals()
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/tests/dep/testAtom.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/pym/portage/tests/dep/testAtom.py b/pym/portage/tests/dep/testAtom.py
index a4972905..35f8e5f2 100644
--- a/pym/portage/tests/dep/testAtom.py
+++ b/pym/portage/tests/dep/testAtom.py
@@ -87,3 +87,53 @@ class TestAtom(TestCase):
for atom, allow_wildcard in tests_xfail:
self.assertRaisesMsg(atom, portage.exception.InvalidAtom, Atom, atom)
+
+ def test_violated_conditionals(self):
+ test_cases = (
+ ("dev-libs/A", ["foo"], None, "dev-libs/A"),
+ ("dev-libs/A[foo]", [], None, "dev-libs/A[foo]"),
+ ("dev-libs/A[foo]", ["foo"], None, "dev-libs/A"),
+ ("dev-libs/A[foo]", [], [], "dev-libs/A[foo]"),
+ ("dev-libs/A[foo]", ["foo"], [], "dev-libs/A"),
+
+ ("dev-libs/A:0[foo]", ["foo"], [], "dev-libs/A:0"),
+
+ ("dev-libs/A[foo,-bar]", [], None, "dev-libs/A[foo]"),
+ ("dev-libs/A[-foo,bar]", [], None, "dev-libs/A[bar]"),
+
+ ("dev-libs/A[a,b=,!c=,d?,!e?,-f]", [], [], "dev-libs/A[a,!c=]"),
+
+ ("dev-libs/A[a,b=,!c=,d?,!e?,-f]", ["a"], [], "dev-libs/A[!c=]"),
+ ("dev-libs/A[a,b=,!c=,d?,!e?,-f]", ["b"], [], "dev-libs/A[a,b=,!c=]"),
+ ("dev-libs/A[a,b=,!c=,d?,!e?,-f]", ["c"], [], "dev-libs/A[a]"),
+ ("dev-libs/A[a,b=,!c=,d?,!e?,-f]", ["d"], [], "dev-libs/A[a,!c=]"),
+ ("dev-libs/A[a,b=,!c=,d?,!e?,-f]", ["e"], [], "dev-libs/A[a,!e?,!c=]"),
+ ("dev-libs/A[a,b=,!c=,d?,!e?,-f]", ["f"], [], "dev-libs/A[a,-f,!c=]"),
+
+ ("dev-libs/A[a,b=,!c=,d?,!e?,-f]", ["a"], ["a"], "dev-libs/A[!c=]"),
+ ("dev-libs/A[a,b=,!c=,d?,!e?,-f]", ["b"], ["b"], "dev-libs/A[a,!c=]"),
+ ("dev-libs/A[a,b=,!c=,d?,!e?,-f]", ["c"], ["c"], "dev-libs/A[a,!c=]"),
+ ("dev-libs/A[a,b=,!c=,d?,!e?,-f]", ["d"], ["d"], "dev-libs/A[a,!c=]"),
+ ("dev-libs/A[a,b=,!c=,d?,!e?,-f]", ["e"], ["e"], "dev-libs/A[a,!c=]"),
+ ("dev-libs/A[a,b=,!c=,d?,!e?,-f]", ["f"], ["f"], "dev-libs/A[a,-f,!c=]"),
+ )
+
+ test_cases_xfail = (
+ ("dev-libs/A[a,b=,!c=,d?,!e?,-f]", [], None),
+ )
+
+ for atom, other_use, parent_use, expected_violated_atom in test_cases:
+ a = Atom(atom)
+ violated_atom = a.violated_conditionals(other_use, parent_use)
+ if parent_use is None:
+ fail_msg = "Atom: %s, other_use: %s, parent_use: %s, got: %s, expected: %s" % \
+ (atom, " ".join(other_use), "None", str(violated_atom), expected_violated_atom)
+ else:
+ fail_msg = "Atom: %s, other_use: %s, parent_use: %s, got: %s, expected: %s" % \
+ (atom, " ".join(other_use), " ".join(parent_use), str(violated_atom), expected_violated_atom)
+ self.assertEqual(str(violated_atom), expected_violated_atom, fail_msg)
+
+ for atom, other_use, parent_use in test_cases_xfail:
+ a = Atom(atom)
+ self.assertRaisesMsg(atom, portage.exception.InvalidAtom, \
+ a.violated_conditionals, other_use, parent_use)