From bea49754d557d2b8ef7b23dea5a97636f3cef084 Mon Sep 17 00:00:00 2001 From: Alec Warner Date: Fri, 2 Feb 2007 00:36:52 +0000 Subject: remove redundant directory now svn path=/main/trunk/; revision=5871 --- pym/portage/tests/util/__init__.py | 5 +++ pym/portage/tests/util/test_grabdict.py | 12 ++++++ pym/portage/tests/util/test_normalizedPath.py | 15 +++++++ pym/portage/tests/util/test_stackDictList.py | 18 ++++++++ pym/portage/tests/util/test_stackDicts.py | 37 +++++++++++++++++ pym/portage/tests/util/test_stackLists.py | 20 +++++++++ pym/portage/tests/util/test_uniqueArray.py | 26 ++++++++++++ pym/portage/tests/util/test_varExpand.py | 60 +++++++++++++++++++++++++++ 8 files changed, 193 insertions(+) create mode 100644 pym/portage/tests/util/__init__.py create mode 100644 pym/portage/tests/util/test_grabdict.py create mode 100644 pym/portage/tests/util/test_normalizedPath.py create mode 100644 pym/portage/tests/util/test_stackDictList.py create mode 100644 pym/portage/tests/util/test_stackDicts.py create mode 100644 pym/portage/tests/util/test_stackLists.py create mode 100644 pym/portage/tests/util/test_uniqueArray.py create mode 100644 pym/portage/tests/util/test_varExpand.py (limited to 'pym/portage/tests/util') 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 ) ) -- cgit v1.2.3-1-g7c22