summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlec Warner <antarus@gentoo.org>2007-01-10 12:30:05 +0000
committerAlec Warner <antarus@gentoo.org>2007-01-10 12:30:05 +0000
commit412a1a1278ec55630d9fe776e4ea7c1edfaceead (patch)
tree13ad92cfee630f091d55fef01bf58839ee530296
parent6959744608eb2f2bdb73847108328b3230e9ed8d (diff)
downloadportage-412a1a1278ec55630d9fe776e4ea7c1edfaceead.tar.gz
portage-412a1a1278ec55630d9fe776e4ea7c1edfaceead.tar.bz2
portage-412a1a1278ec55630d9fe776e4ea7c1edfaceead.zip
rework test import code, rename test_vercmp to be more generic, add tests for =* glob matches
svn path=/main/trunk/; revision=5522
-rw-r--r--tests/__init__.py7
-rw-r--r--tests/test_atoms.py (renamed from tests/test_vercmp.py)37
-rw-r--r--tests/test_util.py3
3 files changed, 36 insertions, 11 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
index 6acf0c99f..a32ca05d3 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -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
diff --git a/tests/test_vercmp.py b/tests/test_atoms.py
index 624950cf5..499920f21 100644
--- a/tests/test_vercmp.py
+++ b/tests/test_atoms.py
@@ -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)
-
diff --git a/tests/test_util.py b/tests/test_util.py
index 59d82b9ba..e16da6c1d 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -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)
-