Tests: Extend dep/testAtom.py and add test cases for wildcards Two failing tests...
authorSebastian Luther <SebastianLuther@gmx.de>
Fri, 23 Jul 2010 12:28:19 +0000 (14:28 +0200)
committerZac Medico <zmedico@gentoo.org>
Fri, 23 Jul 2010 16:47:13 +0000 (09:47 -0700)
pym/portage/tests/dep/testAtom.py

index 8d69e425f301c38b4bc06cffd791a63e6364916b..7457babb7753db837b0bf93e02a6c1c0903296ff 100644 (file)
@@ -14,16 +14,53 @@ class TestAtom(TestCase):
        def testAtom(self):
 
                tests = [
-                         ( "=sys-apps/portage-2.1-r1:0[doc]",
-                               ('=',  'sys-apps/portage', '2.1-r1', '0', '[doc]') ),
+                         ( "=sys-apps/portage-2.1-r1:0[doc,a=,!b=,c?,!d?,-e]",
+                               ('=',  'sys-apps/portage', '2.1-r1', '0', '[doc,a=,!b=,c?,!d?,-e]'), False ),
                          ( "=sys-apps/portage-2.1-r1*:0[doc]",
-                               ('=*',  'sys-apps/portage', '2.1-r1', '0', '[doc]') ),
+                               ('=*',  'sys-apps/portage', '2.1-r1', '0', '[doc]'), False ),
                          ( "sys-apps/portage:0[doc]",
-                               (None,  'sys-apps/portage', None, '0', '[doc]') ),
+                               (None,  'sys-apps/portage', None, '0', '[doc]'), False ),
+                         ( "sys-apps/portage:0[doc]",
+                               (None,  'sys-apps/portage', None, '0', '[doc]'), False ),
+                         ( "*/*",
+                               (None,  '*/*', None, None, None), True ),
+                         ( "sys-apps/*",
+                               (None,  'sys-apps/*', None, None, None), True ),
+                         ( "*/portage",
+                               (None,  '*/portage', None, None, None), True )
+               ]
+               
+               tests_xfail = [
+                       ( "cat/pkg[a!]", False ),
+                       #( "cat/pkg[a-]", False ),
+                       ( "cat/pkg[!a]", False ),
+                       ( "cat/pkg[!a!]", False ),
+                       ( "cat/pkg[!a-]", False ),
+                       ( "cat/pkg[-a=]", False ),
+                       ( "cat/pkg[-a?]", False ),
+                       ( "cat/pkg[-a!]", False ),
+                       #( "cat/pkg[-a-]", False ),
+                       ( "cat/pkg[=a]", False ),
+                       ( "cat/pkg[=a=]", False ),
+                       ( "cat/pkg[=a?]", False ),
+                       ( "cat/pkg[=a!]", False ),
+                       ( "cat/pkg[=a-]", False ),
+                       ( "cat/pkg[?a]", False ),
+                       ( "cat/pkg[?a=]", False ),
+                       ( "cat/pkg[?a?]", False ),
+                       ( "cat/pkg[?a!]", False ),
+                       ( "cat/pkg[?a-]", False ),
+                       ( "sys-apps/portage[doc]:0", False ),
+                       ( "*/*", False ),
+                       ( "sys-apps/*", False ),
+                       ( "*/portage", False ),
+                       ( "*/**", True ),
+                       ( "*/portage[use]", True ),
+                       ( "*/portage:slot", True )
                ]
 
-               for atom, parts in tests:
-                       a = Atom(atom)
+               for atom, parts, allow_wildcard in tests:
+                       a = Atom(atom, allow_wildcard=allow_wildcard)
                        op, cp, ver, slot, use = parts
                        self.assertEqual( op, a.operator,
                                msg="Atom('%s').operator == '%s'" % ( atom, a.operator ) )
@@ -37,5 +74,12 @@ class TestAtom(TestCase):
                                msg="Atom('%s').cpv == '%s'" % ( atom, a.cpv ) )
                        self.assertEqual( slot, a.slot,
                                msg="Atom('%s').slot == '%s'" % ( atom, a.slot ) )
-                       self.assertEqual( use, str(a.use),
+                       if a.use:
+                               expected_use = str(a.use)
+                       else:
+                               expected_use = None
+                       self.assertEqual( use, expected_use,
                                msg="Atom('%s').use == '%s'" % ( atom, a.use ) )
+
+               for atom, allow_wildcard in tests_xfail:
+                       self.assertRaisesMsg(atom, portage.exception.InvalidAtom, Atom, atom)