add some portage_util tests
authorAlec Warner <antarus@gentoo.org>
Fri, 8 Dec 2006 01:57:30 +0000 (01:57 -0000)
committerAlec Warner <antarus@gentoo.org>
Fri, 8 Dec 2006 01:57:30 +0000 (01:57 -0000)
svn path=/main/trunk/; revision=5217

tests/__init__.py
tests/test_util.py [new file with mode: 0644]
tests/test_vercmp.py

index d0d31801dae72ece8efdf2bf3c503b182916a633..1a235ff26f6bd174473e72f4a1b0901be84063f7 100644 (file)
@@ -7,7 +7,7 @@ import unittest
 
 def main():
        
-       tests = ["test_vercmp"]
+       tests = ["test_vercmp", "test_util"]
 
        suite = unittest.TestSuite()
 
diff --git a/tests/test_util.py b/tests/test_util.py
new file mode 100644 (file)
index 0000000..59d82b9
--- /dev/null
@@ -0,0 +1,42 @@
+# test_vercmp.py -- Portage Unit Testing Functionality
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id: test_vercmp.py 5213 2006-12-08 00:12:41Z antarus $
+
+from unittest import TestCase, TestLoader
+
+class UtilTestCase(TestCase):
+       
+       def testUniqueArray(self):
+               pass
+               
+       def testVarexpand(self):
+               pass
+               
+       def testStackLists(self):
+               pass
+       
+       def testStackDicts(self):
+               pass
+       
+       def testStackDictList(self):
+               from portage_util import stack_dictlist
+               
+               tests = [ ({'a':'b'},{'x':'y'},False,{'a':['b'],'x':['y']}) ]
+               tests.append(( {'KEYWORDS':['alpha','x86']},{'KEYWORDS':['-*']},True,{} ))
+               tests.append(( {'KEYWORDS':['alpha','x86']},{'KEYWORDS':['-x86']},True,{'KEYWORDS':['alpha']} ))
+               for test in tests:
+                       self.failUnless(stack_dictlist([test[0],test[1]],incremental=test[2]) == test[3],
+                               msg="%s and %s combined, was expecting: %s and got: %s" % (test[0],test[1],test[3],
+                               stack_dictlist([test[0],test[1]],incremental=test[2])) )
+
+       def testNormalizePath(self):
+               
+               from portage_util import normalize_path
+               path = "///foo/bar/baz"
+               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)
+
index ffab892edb3ef37c4634abad30083d22e670329a..624950cf52a415b4793842af9512aac5b6355682 100644 (file)
@@ -42,6 +42,5 @@ class VerCmpTestCase(TestCase):
                        self.failIf( vercmp( test[0], test[1]) == 0, msg="%s == %s? Wrong!" % (test[0],test[1]))
 
 def suite():
-       suite = TestLoader().loadTestsFromTestCase(VerCmpTestCase)
-       return suite
+       return TestLoader().loadTestsFromTestCase(VerCmpTestCase)