From e56e1c1caaa08325fdf398ac385bb804aa46c269 Mon Sep 17 00:00:00 2001 From: Alec Warner Date: Thu, 1 Feb 2007 19:00:56 +0000 Subject: [PATCH] apparently I'm retarded and missed some of the tests.. svn path=/main/trunk/; revision=5864 --- tests/__init__.py | 54 --------------- tests/portage/__init__.py | 4 -- tests/portage/dep/__init__.py | 4 -- tests/portage/dep/test_dep_getcpv.py | 41 ----------- tests/portage/dep/test_dep_getslot.py | 31 --------- tests/portage/dep/test_dep_getusedeps.py | 39 ----------- tests/portage/dep/test_get_operator.py | 31 --------- tests/portage/dep/test_isjustname.py | 25 ------- tests/portage/dep/test_isvalidatom.py | 38 ----------- tests/portage/dep/test_match_from_list.py | 31 --------- tests/portage/news/__init__.py | 4 -- tests/portage/news/test_NewsItem.py | 83 ----------------------- tests/portage/util/__init__.py | 5 -- tests/portage/util/test_grabdict.py | 12 ---- tests/portage/util/test_normalizedPath.py | 15 ---- tests/portage/util/test_stackDictList.py | 18 ----- tests/portage/util/test_stackDicts.py | 37 ---------- tests/portage/util/test_stackLists.py | 20 ------ tests/portage/util/test_uniqueArray.py | 26 ------- tests/portage/util/test_varExpand.py | 60 ---------------- tests/portage/versions/__init__.py | 4 -- tests/portage/versions/test_vercmp.py | 40 ----------- tests/runTests | 22 ------ 23 files changed, 644 deletions(-) delete mode 100644 tests/__init__.py delete mode 100644 tests/portage/__init__.py delete mode 100644 tests/portage/dep/__init__.py delete mode 100644 tests/portage/dep/test_dep_getcpv.py delete mode 100644 tests/portage/dep/test_dep_getslot.py delete mode 100644 tests/portage/dep/test_dep_getusedeps.py delete mode 100644 tests/portage/dep/test_get_operator.py delete mode 100644 tests/portage/dep/test_isjustname.py delete mode 100644 tests/portage/dep/test_isvalidatom.py delete mode 100644 tests/portage/dep/test_match_from_list.py delete mode 100644 tests/portage/news/__init__.py delete mode 100644 tests/portage/news/test_NewsItem.py delete mode 100644 tests/portage/util/__init__.py delete mode 100644 tests/portage/util/test_grabdict.py delete mode 100644 tests/portage/util/test_normalizedPath.py delete mode 100644 tests/portage/util/test_stackDictList.py delete mode 100644 tests/portage/util/test_stackDicts.py delete mode 100644 tests/portage/util/test_stackLists.py delete mode 100644 tests/portage/util/test_uniqueArray.py delete mode 100644 tests/portage/util/test_varExpand.py delete mode 100644 tests/portage/versions/__init__.py delete mode 100644 tests/portage/versions/test_vercmp.py delete mode 100755 tests/runTests diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index 59152e057..000000000 --- a/tests/__init__.py +++ /dev/null @@ -1,54 +0,0 @@ -# tests/__init__.py -- Portage Unit Test functionality -# Copyright 2006 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Id$ - -import os, unittest - -def main(): - - testDirs = ["portage", "portage/util","portage/versions", "portage/dep"] - - suite = unittest.TestSuite() - - basedir = os.path.dirname(__file__) - for mydir in testDirs: - suite.addTests(getTests(os.path.join(basedir, mydir), basedir) ) - - return unittest.TextTestRunner(verbosity=2).run(suite) - -def my_import(name): - mod = __import__(name) - components = name.split('.') - for comp in components[1:]: - mod = getattr(mod, comp) - return mod - -def getTests( path, base_path ): - """ - - path is the path to a given subdir ( 'portage/' for example) - This does a simple filter on files in that dir to give us modules - to import - - """ - import os - files = os.listdir( path ) - files = [ f[:-3] for f in files if f.startswith("test_") and f.endswith(".py") ] - parent_path = path[len(base_path)+1:] - parent_module = ".".join(("tests", parent_path)) - result = [] - for mymodule in files: - try: - # Make the trailing / a . for module importing - modname = ".".join((parent_module, mymodule)) - mod = my_import(modname) - result.append( unittest.TestLoader().loadTestsFromModule(mod) ) - except ImportError: - raise - return result - -test_cpvs = ['sys-apps/portage','virtual/portage'] -test_versions = ['1.0', '1.0-r1','2.3_p4','1.0_alpha57'] -test_slots = [ None, '1','gentoo-sources-2.6.17','spankywashere'] -test_usedeps = ['foo','-bar', ['foo','bar'],['foo','-bar'] ] diff --git a/tests/portage/__init__.py b/tests/portage/__init__.py deleted file mode 100644 index 920c2f7e3..000000000 --- a/tests/portage/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# tests/portage/__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/tests/portage/dep/__init__.py b/tests/portage/dep/__init__.py deleted file mode 100644 index a3226c133..000000000 --- a/tests/portage/dep/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# tests/portage.dep/__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/tests/portage/dep/test_dep_getcpv.py b/tests/portage/dep/test_dep_getcpv.py deleted file mode 100644 index 11fd1a723..000000000 --- a/tests/portage/dep/test_dep_getcpv.py +++ /dev/null @@ -1,41 +0,0 @@ -# test_dep_getcpv.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.dep import dep_getcpv - -class DepGetCPV(TestCase): - """ A simple testcase for isvalidatom - """ - - def testDepGetCPV(self): - - prefix_ops = ["<", ">", "=", "~", "!", "<=", - ">=", "!=", "!<", "!>", "!~",""] - - bad_prefix_ops = [ ">~", "<~", "~>", "~<" ] - postfix_ops = [ "*", "" ] - - cpvs = ["sys-apps/portage", "sys-apps/portage-2.1", "sys-apps/portage-2.1", - "sys-apps/portage-2.1"] - slots = [None,":",":2"] - for cpv in cpvs: - for slot in slots: - for prefix in prefix_ops: - for postfix in postfix_ops: - if slot: - self.assertEqual( dep_getcpv( - prefix + cpv + slot + postfix ), cpv ) - else: - self.assertEqual( dep_getcpv( - prefix + cpv + postfix ), cpv ) - for prefix in bad_prefix_ops: - for postfix in postfix_ops: - if slot: - self.assertNotEqual( dep_getcpv( - prefix + cpv + slot + postfix ), cpv ) - else: - self.assertNotEqual( dep_getcpv( - prefix + cpv + postfix ), cpv ) \ No newline at end of file diff --git a/tests/portage/dep/test_dep_getslot.py b/tests/portage/dep/test_dep_getslot.py deleted file mode 100644 index d3b38917a..000000000 --- a/tests/portage/dep/test_dep_getslot.py +++ /dev/null @@ -1,31 +0,0 @@ -# test_dep_getslot.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.dep import dep_getslot - -class DepGetSlot(TestCase): - """ A simple testcase for isvalidatom - """ - - def testDepGetSlot(self): - - slot_char = ":" - slots = ( "a", "1.2", "1", "IloveVapier", None ) - cpvs = ["sys-apps/portage"] - versions = ["2.1.1","2.1-r1"] - for cpv in cpvs: - for version in versions: - for slot in slots: - mycpv = cpv[:] - if version: - cpv += version - if slot: - self.assertEqual( dep_getslot( - cpv + slot_char + slot ), slot ) - else: - self.assertEqual( dep_getslot( cpv ), slot ) - - self.assertEqual( dep_getslot( "sys-apps/portage:"), "" ) diff --git a/tests/portage/dep/test_dep_getusedeps.py b/tests/portage/dep/test_dep_getusedeps.py deleted file mode 100644 index d191d43cc..000000000 --- a/tests/portage/dep/test_dep_getusedeps.py +++ /dev/null @@ -1,39 +0,0 @@ -# test_dep_getusedeps.py -- Portage Unit Testing Functionality -# Copyright 2007 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Id: test_dep_getslot.py 5794 2007-01-27 18:16:08Z antarus $ - -from unittest import TestCase -from portage.dep import dep_getusedeps - -import sys -from portage.tests import test_cpvs, test_slots, test_versions, test_usedeps - -class DepGetUseDeps(TestCase): - """ A simple testcase for dep_getusedeps - """ - - def testDepGetUseDeps(self): - - - for mycpv in test_cpvs: - for version in test_versions: - for slot in test_slots: - for use in test_usedeps: - cpv = mycpv[:] - if version: - cpv += version - if slot: - cpv += ":" + slot - if isinstance( use, list ): - for u in use: - cpv = cpv + "[" + u + "]" - self.assertEqual( dep_getusedeps( - cpv ), use ) - else: - if len(use): - self.assertEqual( dep_getusedeps( - cpv + "[" + use + "]" ), [use] ) - else: - self.assertEqual( dep_getusedeps( - cpv + "[" + use + "]" ), [] ) diff --git a/tests/portage/dep/test_get_operator.py b/tests/portage/dep/test_get_operator.py deleted file mode 100644 index b41fab0d5..000000000 --- a/tests/portage/dep/test_get_operator.py +++ /dev/null @@ -1,31 +0,0 @@ -# test_match_from_list.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.dep import get_operator - -class GetOperator(TestCase): - - def testGetOperator(self): - - # get_operator does not validate operators - tests = [ ( "~", "~" ), ( "=", "=" ), ( ">", ">" ), - ( ">=", ">=" ), ( "<=", "<=" ) , ( "", None ), - ( ">~", ">" ), ("~<", "~"), ( "=~", "=" ), - ( "=>", "=" ), ("=<", "=") ] - - test_cpvs = ["sys-apps/portage","sys-apps/portage-2.1"] - slots = [ None,"1","linux-2.5.6" ] - for cpv in test_cpvs: - for test in tests: - for slot in slots: - atom = cpv[:] - if slot: - atom += ":" + slot - result = get_operator( test[0] + atom ) - self.assertEqual( result, test[1] ) - - result = get_operator( "=sys-apps/portage*" ) - self.assertEqual( result , "=*" ) diff --git a/tests/portage/dep/test_isjustname.py b/tests/portage/dep/test_isjustname.py deleted file mode 100644 index e419e3f26..000000000 --- a/tests/portage/dep/test_isjustname.py +++ /dev/null @@ -1,25 +0,0 @@ -# test_isjustname.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.dep import isjustname - -class IsJustName(TestCase): - - def testIsJustName(self): - - cats = ( "", "sys-apps/", "foo/", "virtual/" ) - pkgs = ( "portage", "paludis", "pkgcore", "notARealPkg" ) - vers = ( "", "-2.0-r3", "-1.0_pre2", "-3.1b" ) - - for pkg in pkgs: - for cat in cats: - for ver in vers: - if len(ver): - self.assertFalse( isjustname( cat + pkg + ver ), - msg="isjustname(%s) is True!" % (cat + pkg + ver) ) - else: - self.assertTrue( isjustname( cat + pkg + ver ), - msg="isjustname(%s) is False!" % (cat + pkg + ver) ) diff --git a/tests/portage/dep/test_isvalidatom.py b/tests/portage/dep/test_isvalidatom.py deleted file mode 100644 index 88250e96c..000000000 --- a/tests/portage/dep/test_isvalidatom.py +++ /dev/null @@ -1,38 +0,0 @@ -# test_isvalidatom.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.dep import isvalidatom - -class IsValidAtom(TestCase): - """ A simple testcase for isvalidatom - """ - - def testIsValidAtom(self): - - tests = [ ( "sys-apps/portage", True ), - ( "=sys-apps/portage-2.1", True ), - ( "=sys-apps/portage-2.1*", True ), - ( ">=sys-apps/portage-2.1", True ), - ( "<=sys-apps/portage-2.1", True ), - ( ">sys-apps/portage-2.1", True ), - ( "~cate-gory/foo-1.0", False ), - ( ">~category/foo-1.0", False ), - ( "<~category/foo-1.0", False ), - ( "###cat/foo-1.0", False ), - ( "~sys-apps/portage", False ), - ( "portage", False ) ] - - for test in tests: - if test[1]: - atom_type = "valid" - else: - atom_type = "invalid" - self.assertEqual( bool(isvalidatom( test[0] )), test[1], - msg="isvalidatom(%s) != %s" % ( test[0], test[1] ) ) diff --git a/tests/portage/dep/test_match_from_list.py b/tests/portage/dep/test_match_from_list.py deleted file mode 100644 index 4868184a6..000000000 --- a/tests/portage/dep/test_match_from_list.py +++ /dev/null @@ -1,31 +0,0 @@ -# test_match_from_list.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.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: - self.assertEqual( len(match_from_list( test[0], [test[1]] )), 1 ) - - def testEqualGlobFail(self): - tests = [ ("=sys-apps/portage-2*", "sys-apps/portage-2.1" ), - ("=sys-apps/portage-2.1*", "sys-apps/portage-2.1.2" ) ] - for test in tests: - try: - self.assertEqual( len( match_from_list( test[0], [test[1]] ) ), 1 ) - except TypeError: # failure is ok here - pass diff --git a/tests/portage/news/__init__.py b/tests/portage/news/__init__.py deleted file mode 100644 index aeaa49195..000000000 --- a/tests/portage/news/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# tests/portage.news/__init__.py -- Portage Unit Test functionality -# Copyright 2007 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Id$ diff --git a/tests/portage/news/test_NewsItem.py b/tests/portage/news/test_NewsItem.py deleted file mode 100644 index 22ef298d4..000000000 --- a/tests/portage/news/test_NewsItem.py +++ /dev/null @@ -1,83 +0,0 @@ -# test_NewsItem.py -- Portage Unit Testing Functionality -# Copyright 2007 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Id: test_varExpand.py 5596 2007-01-12 08:08:53Z antarus $ - -from unittest import TestCase, TestLoader -from portage.news import NewsItem -from portage.const import PROFILE_PATH - -class NewsItemTestCase(TestCase): - - self.fakeItem = """ -Title: YourSQL Upgrades from 4.0 to 4.1 -Author: Ciaran McCreesh -Content-Type: text/plain -Posted: 01-Nov-2005 -Revision: 1 -#Display-If-Installed: -#Display-If-Profile: -#Display-If-Arch: - -YourSQL databases created using YourSQL version 4.0 are incompatible -with YourSQL version 4.1 or later. There is no reliable way to -automate the database format conversion, so action from the system -administrator is required before an upgrade can take place. - -Please see the Gentoo YourSQL Upgrade Guide for instructions: - - http://www.gentoo.org/doc/en/yoursql-upgrading.xml - -Also see the official YourSQL documentation: - - http://dev.yoursql.com/doc/refman/4.1/en/upgrading-from-4-0.html - -After upgrading, you should also recompile any packages which link -against YourSQL: - - revdep-rebuild --library=libyoursqlclient.so.12 - -The revdep-rebuild tool is provided by app-portage/gentoolkit. -""" - - from portage import settings - import time - - def testDisplayIfProfile(): - from portage.const import PROFILE_PATH - tmpItem = self.fakeItem.replace("#Display-If-Profile:", "Display-If-Profile: %s" % - os.readlink( PROFILE_PATH ) ) - - item = _processItem(tmpItem) - self.assertTrue( item.isRelevant( os.readlink( PROFILE_PATH ) ), - msg="Expected %s to be relevant, but it was not!" % tmpItem ) - - def testDisplayIfInstalled(): - tmpItem = self.fakeItem.replace("#Display-If-Installed:", "Display-If-Profile: %s" % - "sys-apps/portage" ) - - item = _processItem(tmpItem) - self.assertTrue( item.isRelevant( portage.settings ), - msg="Expected %s to be relevant, but it was not!" % tmpItem ) - - - def testDisplayIfKeyword(): - from portage import settings - tmpItem = self.fakeItem.replace("#Display-If-Keyword:", "Display-If-Keyword: %s" % - settings["ACCEPT_KEYWORDS"].split()[0] ) - - item = _processItem(tmpItem) - self.assertTrue( item.isRelevant( os.readlink( PROFILE_PATH ) ), - msg="Expected %s to be relevant, but it was not!" % tmpItem ) - - - def _processItem( self, item ): - - path = os.path.join( settings["PORTAGE_TMPDIR"], str(time.time()) - f = open( os.path.join( path ) - f.write(item) - f.close - try: - return NewsItem( path, 0 ) - except TypeError: - self.fail("Error while processing news item %s" % path ) diff --git a/tests/portage/util/__init__.py b/tests/portage/util/__init__.py deleted file mode 100644 index 9a66903d1..000000000 --- a/tests/portage/util/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -# 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/tests/portage/util/test_grabdict.py b/tests/portage/util/test_grabdict.py deleted file mode 100644 index 9f7b58921..000000000 --- a/tests/portage/util/test_grabdict.py +++ /dev/null @@ -1,12 +0,0 @@ -# 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/tests/portage/util/test_normalizedPath.py b/tests/portage/util/test_normalizedPath.py deleted file mode 100644 index bd575d266..000000000 --- a/tests/portage/util/test_normalizedPath.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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/tests/portage/util/test_stackDictList.py b/tests/portage/util/test_stackDictList.py deleted file mode 100644 index 9e7a38ba1..000000000 --- a/tests/portage/util/test_stackDictList.py +++ /dev/null @@ -1,18 +0,0 @@ -# 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/tests/portage/util/test_stackDicts.py b/tests/portage/util/test_stackDicts.py deleted file mode 100644 index 9d9637440..000000000 --- a/tests/portage/util/test_stackDicts.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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/tests/portage/util/test_stackLists.py b/tests/portage/util/test_stackLists.py deleted file mode 100644 index 3fc028323..000000000 --- a/tests/portage/util/test_stackLists.py +++ /dev/null @@ -1,20 +0,0 @@ -# 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/tests/portage/util/test_uniqueArray.py b/tests/portage/util/test_uniqueArray.py deleted file mode 100644 index 62a315321..000000000 --- a/tests/portage/util/test_uniqueArray.py +++ /dev/null @@ -1,26 +0,0 @@ -# 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/tests/portage/util/test_varExpand.py b/tests/portage/util/test_varExpand.py deleted file mode 100644 index 47dc7de2c..000000000 --- a/tests/portage/util/test_varExpand.py +++ /dev/null @@ -1,60 +0,0 @@ -# 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 ) ) diff --git a/tests/portage/versions/__init__.py b/tests/portage/versions/__init__.py deleted file mode 100644 index 5e5b216fb..000000000 --- a/tests/portage/versions/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# tests/portage.versions/__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/tests/portage/versions/test_vercmp.py b/tests/portage/versions/test_vercmp.py deleted file mode 100644 index ee3d37741..000000000 --- a/tests/portage/versions/test_vercmp.py +++ /dev/null @@ -1,40 +0,0 @@ -# test_vercmp.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.versions import vercmp - -class VerCmpTestCase(TestCase): - """ A simple testCase for portage.versions.vercmp() - """ - - def testVerCmpGreater(self): - - tests = [ ( "6.0", "5.0"), ("5.0","5")] - for test in tests: - self.failIf( vercmp( test[0], test[1] ) <= 0, msg="%s < %s? Wrong!" % (test[0],test[1]) ) - - def testVerCmpLess(self): - """ - pre < alpha < beta < rc < p -> test each of these, they are inductive (or should be..) - """ - tests = [ ( "4.0", "5.0"), ("5", "5.0"), ("1.0_pre2","1.0_p2"), - ("1.0_alpha2", "1.0_p2"),("1.0_alpha1", "1.0_beta1"),("1.0_beta3","1.0_rc3")] - for test in tests: - self.failIf( vercmp( test[0], test[1]) >= 0, msg="%s > %s? Wrong!" % (test[0],test[1])) - - - def testVerCmpEqual(self): - - tests = [ ("4.0", "4.0") ] - for test in tests: - self.failIf( vercmp( test[0], test[1]) != 0, msg="%s != %s? Wrong!" % (test[0],test[1])) - - def testVerNotEqual(self): - - tests = [ ("1","2"),("1.0_alpha","1.0_pre"),("1.0_beta","1.0_alpha"), - ("0", "0.0")] - for test in tests: - self.failIf( vercmp( test[0], test[1]) == 0, msg="%s == %s? Wrong!" % (test[0],test[1])) diff --git a/tests/runTests b/tests/runTests deleted file mode 100755 index c44d36788..000000000 --- a/tests/runTests +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/python -# runTests.py -- Portage Unit Test Functionality -# Copyright 2006 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Id$ - - -import os, sys -import os.path as osp - -# Insert our parent dir so we can do shiny import "tests" -# This line courtesy of Marienz and Pkgcore ;) -sys.path.insert(0, osp.dirname(osp.dirname(osp.abspath(__file__)))) - -# Grab SVN portage files instead of normal ones. -sys.path.insert(0, os.path.join(sys.path[0], "pym")) - -import tests -if __name__ == "__main__": - result = tests.main() - if result.failures: - sys.exit(1) -- 2.26.2