Tests: dep/test_match_from_list: Complete rewrite
authorSebastian Luther <SebastianLuther@gmx.de>
Fri, 23 Jul 2010 12:53:57 +0000 (14:53 +0200)
committerZac Medico <zmedico@gentoo.org>
Fri, 23 Jul 2010 16:47:13 +0000 (09:47 -0700)
pym/portage/tests/dep/test_match_from_list.py

index d6df1f29f1fe3085a0f27e0620cba95f877d5823..e5a418cd8d22cca7763b5d027d6590ae92609271 100644 (file)
@@ -5,26 +5,22 @@
 from portage.tests import TestCase
 from portage.dep import match_from_list
 
-class AtomCmpEqualGlob(TestCase):
-        """ A simple testcase for =* glob matching
-        """
+class Test_match_from_list(TestCase):
 
-        def testEqualGlobPass(self):
-                tests = [ ("=sys-apps/portage-45*", "sys-apps/portage-045" ),
-                          ("=sys-fs/udev-1*", "sys-fs/udev-123"),
-                          ("=sys-fs/udev-4*", "sys-fs/udev-456" ) ]
+       def testMatch_from_list(self):
+               tests = [ ("=sys-apps/portage-45*", ["sys-apps/portage-045"], ["sys-apps/portage-045"] ),
+                                       ("=sys-fs/udev-1*", ["sys-fs/udev-123"], ["sys-fs/udev-123"]),
+                                       ("=sys-fs/udev-4*", ["sys-fs/udev-456"], ["sys-fs/udev-456"] ),
+                                       ("*/*", ["sys-fs/udev-456"], ["sys-fs/udev-456"] ),
+                                       ("sys-fs/*", ["sys-fs/udev-456"], ["sys-fs/udev-456"] ),
+                                       ("*/udev", ["sys-fs/udev-456"], ["sys-fs/udev-456"] ),
+                                       ("=sys-apps/portage-2*", ["sys-apps/portage-2.1"], ["sys-apps/portage-2.1"] ),
+                                       ("=sys-apps/portage-2.1*", ["sys-apps/portage-2.1.2"], ["sys-apps/portage-2.1.2"] ),
+                                       ("dev-libs/*", ["sys-apps/portage-2.1.2"], [] ),
+                                       ("*/tar", ["sys-apps/portage-2.1.2"], [] ),
+                                       ("*/*", ["dev-libs/A-1", "dev-libs/B-1"], ["dev-libs/A-1", "dev-libs/B-1"] ),
+                                       ("dev-libs/*", ["dev-libs/A-1", "sci-libs/B-1"], ["dev-libs/A-1"] )
+                               ]
 
-# I need to look up the cvs syntax
-#                         ("=sys-fs/udev_cvs*","sys-fs/udev_cvs_pre4" ) ]
-
-                for test in tests:
-                        self.assertEqual( len(match_from_list( test[0], [test[1]] )), 1 )
-
-        def testEqualGlobFail(self):
-                tests = [ ("=sys-apps/portage-2*", "sys-apps/portage-2.1" ),
-                          ("=sys-apps/portage-2.1*", "sys-apps/portage-2.1.2" ) ]
-                for test in tests:
-                        try:
-                                self.assertEqual( len( match_from_list( test[0], [test[1]] ) ), 1 )
-                        except TypeError: # failure is ok here
-                                pass
+               for atom, cpv_list, result in tests:
+                       self.assertEqual( match_from_list( atom, cpv_list ), result )