summaryrefslogtreecommitdiffstats
path: root/pym/portage/tests/util
diff options
context:
space:
mode:
authorAlec Warner <antarus@gentoo.org>2007-02-02 00:36:52 +0000
committerAlec Warner <antarus@gentoo.org>2007-02-02 00:36:52 +0000
commitbea49754d557d2b8ef7b23dea5a97636f3cef084 (patch)
tree19debb4b07cbde1e460d86b9e9b4e0c60a77a152 /pym/portage/tests/util
parentef5a5b15f7810d596cc40812275c19db0241e420 (diff)
downloadportage-bea49754d557d2b8ef7b23dea5a97636f3cef084.tar.gz
portage-bea49754d557d2b8ef7b23dea5a97636f3cef084.tar.bz2
portage-bea49754d557d2b8ef7b23dea5a97636f3cef084.zip
remove redundant directory now
svn path=/main/trunk/; revision=5871
Diffstat (limited to 'pym/portage/tests/util')
-rw-r--r--pym/portage/tests/util/__init__.py5
-rw-r--r--pym/portage/tests/util/test_grabdict.py12
-rw-r--r--pym/portage/tests/util/test_normalizedPath.py15
-rw-r--r--pym/portage/tests/util/test_stackDictList.py18
-rw-r--r--pym/portage/tests/util/test_stackDicts.py37
-rw-r--r--pym/portage/tests/util/test_stackLists.py20
-rw-r--r--pym/portage/tests/util/test_uniqueArray.py26
-rw-r--r--pym/portage/tests/util/test_varExpand.py60
8 files changed, 193 insertions, 0 deletions
diff --git a/pym/portage/tests/util/__init__.py b/pym/portage/tests/util/__init__.py
new file mode 100644
index 000000000..9a66903d1
--- /dev/null
+++ b/pym/portage/tests/util/__init__.py
@@ -0,0 +1,5 @@
+# tests/portage.util/__init__.py -- Portage Unit Test functionality
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
diff --git a/pym/portage/tests/util/test_grabdict.py b/pym/portage/tests/util/test_grabdict.py
new file mode 100644
index 000000000..9f7b58921
--- /dev/null
+++ b/pym/portage/tests/util/test_grabdict.py
@@ -0,0 +1,12 @@
+# test_grabDict.py -- Portage Unit Testing Functionality
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+from unittest import TestCase, TestLoader
+from portage.util import grabdict
+
+class GrabDictTestCase(TestCase):
+
+ def testGrabDictPass(self):
+ pass
diff --git a/pym/portage/tests/util/test_normalizedPath.py b/pym/portage/tests/util/test_normalizedPath.py
new file mode 100644
index 000000000..bd575d266
--- /dev/null
+++ b/pym/portage/tests/util/test_normalizedPath.py
@@ -0,0 +1,15 @@
+# test_normalizePath.py -- Portage Unit Testing Functionality
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+from unittest import TestCase
+
+class NormalizePathTestCase(TestCase):
+
+ def testNormalizePath(self):
+
+ from portage.util import normalize_path
+ path = "///foo/bar/baz"
+ good = "/foo/bar/baz"
+ self.assertEqual(normalize_path(path), good)
diff --git a/pym/portage/tests/util/test_stackDictList.py b/pym/portage/tests/util/test_stackDictList.py
new file mode 100644
index 000000000..9e7a38ba1
--- /dev/null
+++ b/pym/portage/tests/util/test_stackDictList.py
@@ -0,0 +1,18 @@
+# test_stackDictList.py -- Portage Unit Testing Functionality
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+from unittest import TestCase
+
+class StackDictListTestCase(TestCase):
+
+ 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.assertEqual(
+ stack_dictlist([test[0],test[1]],incremental=test[2]), test[3] )
diff --git a/pym/portage/tests/util/test_stackDicts.py b/pym/portage/tests/util/test_stackDicts.py
new file mode 100644
index 000000000..9d9637440
--- /dev/null
+++ b/pym/portage/tests/util/test_stackDicts.py
@@ -0,0 +1,37 @@
+# test_stackDicts.py -- Portage Unit Testing Functionality
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+from unittest import TestCase
+from portage.util import stack_dicts
+
+
+class StackDictsTestCase(TestCase):
+
+ def testStackDictsPass(self):
+
+ tests = [ ( [ { "a":"b" }, { "b":"c" } ], { "a":"b", "b":"c" },
+ False, [], False ),
+ ( [ { "a":"b" }, { "a":"c" } ], { "a":"b c" },
+ True, [], False ),
+ ( [ { "a":"b" }, { "a":"c" } ], { "a":"b c" },
+ False, ["a"], False ),
+ ( [ { "a":"b" }, None ], { "a":"b" },
+ False, [], True ),
+ ( [ None ], None, False, [], False ),
+ ( [ None, {}], {}, False, [], True ) ]
+
+
+ for test in tests:
+ result = stack_dicts( test[0], test[2], test[3], test[4] )
+ self.assertEqual( result, test[1] )
+
+ def testStackDictsFail(self):
+
+ tests = [ ( [ None, {} ], None, False, [], True ),
+ ( [ { "a":"b"}, {"a":"c" } ], { "a":"b c" },
+ False, [], False ) ]
+ for test in tests:
+ result = stack_dicts( test[0], test[2], test[3], test[4] )
+ self.assertNotEqual( result , test[1] )
diff --git a/pym/portage/tests/util/test_stackLists.py b/pym/portage/tests/util/test_stackLists.py
new file mode 100644
index 000000000..3fc028323
--- /dev/null
+++ b/pym/portage/tests/util/test_stackLists.py
@@ -0,0 +1,20 @@
+# test_stackLists.py -- Portage Unit Testing Functionality
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+from unittest import TestCase
+from portage.util import stack_lists
+
+class StackListsTestCase(TestCase):
+
+ def testStackLists(self):
+
+ tests = [ ( [ ['a','b','c'], ['d','e','f'] ], ['a','c','b','e','d','f'], False ),
+ ( [ ['a','x'], ['b','x'] ], ['a','x','b'], False ),
+ ( [ ['a','b','c'], ['-*'] ], [], True ),
+ ( [ ['a'], ['-a'] ], [], True ) ]
+
+ for test in tests:
+ result = stack_lists( test[0], test[2] )
+ self.assertEqual( result , test[1] )
diff --git a/pym/portage/tests/util/test_uniqueArray.py b/pym/portage/tests/util/test_uniqueArray.py
new file mode 100644
index 000000000..62a315321
--- /dev/null
+++ b/pym/portage/tests/util/test_uniqueArray.py
@@ -0,0 +1,26 @@
+# test_uniqueArray.py -- Portage Unit Testing Functionality
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+from unittest import TestCase
+from portage.util import unique_array
+
+class UniqueArrayTestCase(TestCase):
+
+ def testUniqueArrayPass(self):
+ """
+ test portage.util.uniqueArray()
+ """
+
+ import os
+
+ tests = [ ( ["a","a","a",os,os,[],[],[]], ['a',os,[]] ),
+ ( [1,1,1,2,3,4,4] , [1,2,3,4]) ]
+
+ for test in tests:
+ result = unique_array( test[0] )
+ for item in test[1]:
+ number = result.count(item)
+ self.failIf( number is not 1, msg="%s contains %s of %s, \
+ should be only 1" % (result, number, item) )
diff --git a/pym/portage/tests/util/test_varExpand.py b/pym/portage/tests/util/test_varExpand.py
new file mode 100644
index 000000000..47dc7de2c
--- /dev/null
+++ b/pym/portage/tests/util/test_varExpand.py
@@ -0,0 +1,60 @@
+# test_varExpand.py -- Portage Unit Testing Functionality
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+from unittest import TestCase, TestLoader
+from portage.util import varexpand
+
+class VarExpandTestCase(TestCase):
+
+ def testVarExpandPass(self):
+
+ varDict = { "a":"5", "b":"7", "c":"-5" }
+ for key in varDict.keys():
+ result = varexpand( "$%s" % key, varDict )
+
+ self.failIf( result != varDict[key],
+ msg="Got %s != %s, from varexpand( %s, %s )" % \
+ ( result, varDict[key], "$%s" % key, varDict ) )
+ result = varexpand( "${%s}" % key, varDict )
+ self.failIf( result != varDict[key],
+ msg="Got %s != %s, from varexpand( %s, %s )" % \
+ ( result, varDict[key], "${%s}" % key, varDict ) )
+
+ def testVarExpandDoubleQuotes(self):
+
+ varDict = { "a":"5" }
+ tests = [ ("\"${a}\"", "5") ]
+ for test in tests:
+ result = varexpand( test[0], varDict )
+ self.failIf( result != test[1],
+ msg="Got %s != %s from varexpand( %s, %s )" \
+ % ( result, test[1], test[0], varDict ) )
+
+ def testVarExpandSingleQuotes(self):
+
+ varDict = { "a":"5" }
+ tests = [ ("\'${a}\'", "${a}") ]
+ for test in tests:
+ result = varexpand( test[0], varDict )
+ self.failIf( result != test[1],
+ msg="Got %s != %s from varexpand( %s, %s )" \
+ % ( result, test[1], test[0], varDict ) )
+
+ def testVarExpandFail(self):
+
+ varDict = { "a":"5", "b":"7", "c":"15" }
+
+ testVars = [ "fail" ]
+
+ for var in testVars:
+ result = varexpand( "$%s" % var, varDict )
+ self.failIf( len(result),
+ msg="Got %s == %s, from varexpand( %s, %s )" \
+ % ( result, var, "$%s" % var, varDict ) )
+
+ result = varexpand( "${%s}" % var, varDict )
+ self.failIf( len(result),
+ msg="Got %s == %s, from varexpand( %s, %s )" \
+ % ( result, var, "${%s}" % var, varDict ) )