diff options
author | Sebastian Luther <SebastianLuther@gmx.de> | 2010-07-23 15:21:05 +0200 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-07-23 09:47:13 -0700 |
commit | 853bf94db3f6f40ee761833f57be94f6084af709 (patch) | |
tree | 0de54ca1f5e42137986ff0bec3219c0c7ca98e6e | |
parent | 8d8af133245f42e6a678b390285f7908c29e7730 (diff) | |
download | portage-853bf94db3f6f40ee761833f57be94f6084af709.tar.gz portage-853bf94db3f6f40ee761833f57be94f6084af709.tar.bz2 portage-853bf94db3f6f40ee761833f57be94f6084af709.zip |
Test: Add dep/test_best_match_to_list
-rw-r--r-- | pym/portage/tests/dep/test_best_match_to_list.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/pym/portage/tests/dep/test_best_match_to_list.py b/pym/portage/tests/dep/test_best_match_to_list.py new file mode 100644 index 000000000..c5f4fbbc0 --- /dev/null +++ b/pym/portage/tests/dep/test_best_match_to_list.py @@ -0,0 +1,43 @@ +# test_best_match_to_list.py -- Portage Unit Testing Functionality +# Copyright 2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +from portage.tests import TestCase +from portage.dep import Atom, best_match_to_list + +class Test_best_match_to_list(TestCase): + + def best_match_to_list_wrapper(self, mypkg, mylist): + """ + This function uses best_match_to_list to create sorted + list of matching atoms. + """ + ret = [] + while mylist: + m = best_match_to_list(mypkg, mylist) + if m is not None: + ret.append(m) + mylist.remove(m) + else: + break + + return ret + + def testBest_match_to_list(self): + tests = [ + ("dev-libs/A-1", [Atom("dev-libs/A"), Atom("=dev-libs/A-1")], \ + [Atom("=dev-libs/A-1"), Atom("dev-libs/A")]), + ("dev-libs/A-1", [Atom("dev-libs/B"), Atom("=dev-libs/A-1:0")], \ + [Atom("=dev-libs/A-1:0")]), + ("dev-libs/A-1", [Atom("dev-libs/*", allow_wildcard=True), Atom("=dev-libs/A-1:0")], \ + [Atom("=dev-libs/A-1:0"), Atom("dev-libs/*", allow_wildcard=True)]), + ("dev-libs/A-1", [Atom("*/*", allow_wildcard=True), Atom("dev-libs/*", allow_wildcard=True), \ + Atom("dev-libs/A"), Atom("<=dev-libs/A-2"), Atom("dev-libs/A:0"), \ + Atom("=dev-libs/A-1*"), Atom("~dev-libs/A-1"), Atom("=dev-libs/A-1")], \ + [Atom("=dev-libs/A-1"), Atom("~dev-libs/A-1"), Atom("=dev-libs/A-1*"), \ + Atom("dev-libs/A:0"), Atom("<=dev-libs/A-2"), Atom("dev-libs/A"), \ + Atom("dev-libs/*", allow_wildcard=True), Atom("*/*", allow_wildcard=True)]) + ] + + for pkg, atom_list, result in tests: + self.assertEqual( self.best_match_to_list_wrapper( pkg, atom_list ), result ) |