rework test import code, rename test_vercmp to be more generic, add tests for =*...
authorAlec Warner <antarus@gentoo.org>
Wed, 10 Jan 2007 12:30:05 +0000 (12:30 -0000)
committerAlec Warner <antarus@gentoo.org>
Wed, 10 Jan 2007 12:30:05 +0000 (12:30 -0000)
svn path=/main/trunk/; revision=5522

tests/__init__.py
tests/test_atoms.py [moved from tests/test_vercmp.py with 57% similarity]
tests/test_util.py

index 6acf0c99f6addf4ae89ce0666fed7751ce7426de..a32ca05d322a021e8bc8803e8747399010f47800 100644 (file)
@@ -7,14 +7,15 @@ import unittest
 
 def main():
        
-       tests = ["test_vercmp", "test_util"]
+       tests = ["test_atoms", "test_util"]
 
        suite = unittest.TestSuite()
 
        for mod in tests:
                try:
-                       test_mod = __import__(mod)
-                       suite.addTest(test_mod.suite())
+                       loadMod = __import__(mod)
+                       tmpSuite = unittest.TestLoader().loadTestsFromModule(loadMod)
+                       suite.addTest(tmpSuite)
                except ImportError:
                        pass
 
similarity index 57%
rename from tests/test_vercmp.py
rename to tests/test_atoms.py
index 624950cf52a415b4793842af9512aac5b6355682..499920f2182be3ab087b22ba9994ffd6a3ddcee3 100644 (file)
@@ -6,11 +6,42 @@
 from unittest import TestCase
 from unittest import TestLoader
 from portage_versions import vercmp
+from portage_dep import match_from_list
+
+class AtomCmpEqualGlob(TestCase):
+       """ A simple testcase for =* glob matching
+       """
+
+       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" ) ]
+
+# I need to look up the cvs syntax
+#                        ("=sys-fs/udev_cvs*","sys-fs/udev_cvs_pre4" ) ]
+
+               for test in tests:
+                       try:
+                               self.failIf( len(match_from_list( test[0], test[1] )) < 1,
+                                       msg="%s should match %s!" % (test[0], test[1]) )
+                       except TypeError:
+                               print "%s should match %s!" % (test[0], test[1])
+                               raise
+
+       def testEqualGlobFail(self):
+               tests = [ ("=sys-apps/portage*", "sys-apps/portage-2.1" ),
+                         ("=sys-apps/portage-*", "sys-apps/portage-2.1" ) ]
+               for test in tests:
+                       try:
+                               self.failIf( len( match_from_list( test[0], test[1] ) ),
+                                       msg="%s should match %s!" % (test[0], test[1]) )
+                       except TypeError:
+                               #TypeError means it died parsing, this is OK
+                               pass
 
 class VerCmpTestCase(TestCase):
        """ A simple testCase for portage_versions.vercmp()
        """
-
        
        def testVerCmpGreater(self):
                
@@ -40,7 +71,3 @@ class VerCmpTestCase(TestCase):
                        ("0", "0.0")]
                for test in tests:
                        self.failIf( vercmp( test[0], test[1]) == 0, msg="%s == %s? Wrong!" % (test[0],test[1]))
-
-def suite():
-       return TestLoader().loadTestsFromTestCase(VerCmpTestCase)
-
index 59d82b9badb00c09e09f9faa81e67467de34f795..e16da6c1daba7b59d4dc7193bcaa6d363ee1f500 100644 (file)
@@ -37,6 +37,3 @@ class UtilTestCase(TestCase):
                good = "/foo/bar/baz"
                self.failUnless(normalize_path(path) == good, msg="NormalizePath(%s) failed to produce %s" % (path, good))
 
-def suite():
-       return TestLoader().loadTestsFromTestCase(UtilTestCase)
-