From 4a5cdceeb23550b40551fa880a1929c4774f1998 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 28 Apr 2013 20:08:33 -0400 Subject: [PATCH] tests: clean up style a bit (mostly poor/inconsistent spacing) Signed-off-by: Mike Frysinger --- pym/portage/tests/__init__.py | 20 +- pym/portage/tests/bin/setup_env.py | 44 +- pym/portage/tests/dep/testAtom.py | 254 ++++----- pym/portage/tests/dep/testCheckRequiredUse.py | 188 +++---- pym/portage/tests/dep/testStandalone.py | 26 +- .../tests/dep/test_best_match_to_list.py | 46 +- pym/portage/tests/dep/test_dep_getcpv.py | 16 +- pym/portage/tests/dep/test_dep_getrepo.py | 6 +- pym/portage/tests/dep/test_dep_getslot.py | 10 +- pym/portage/tests/dep/test_dep_getusedeps.py | 12 +- pym/portage/tests/dep/test_get_operator.py | 24 +- pym/portage/tests/dep/test_isjustname.py | 14 +- pym/portage/tests/dep/test_isvalidatom.py | 6 +- pym/portage/tests/dep/test_match_from_list.py | 120 ++-- pym/portage/tests/dep/test_paren_reduce.py | 50 +- pym/portage/tests/dep/test_use_reduce.py | 519 +++++++++--------- pym/portage/tests/ebuild/test_config.py | 4 +- .../env/config/test_PackageKeywordsFile.py | 8 +- .../tests/env/config/test_PackageUseFile.py | 6 +- .../env/config/test_PortageModulesFile.py | 11 +- .../tests/resolver/ResolverPlayground.py | 18 +- pym/portage/tests/resolver/test_autounmask.py | 304 +++++----- .../tests/resolver/test_backtracking.py | 6 +- pym/portage/tests/resolver/test_depclean.py | 100 ++-- .../test_depclean_slot_unavailable.py | 15 +- pym/portage/tests/resolver/test_multirepo.py | 4 +- pym/portage/tests/util/test_stackDictList.py | 12 +- pym/portage/tests/util/test_stackDicts.py | 41 +- pym/portage/tests/util/test_stackLists.py | 18 +- pym/portage/tests/util/test_uniqueArray.py | 14 +- pym/portage/tests/util/test_varExpand.py | 80 +-- .../tests/versions/test_cpv_sort_key.py | 7 +- pym/portage/tests/versions/test_vercmp.py | 38 +- 33 files changed, 1026 insertions(+), 1015 deletions(-) diff --git a/pym/portage/tests/__init__.py b/pym/portage/tests/__init__.py index a46c2db42..d90fe6fc5 100644 --- a/pym/portage/tests/__init__.py +++ b/pym/portage/tests/__init__.py @@ -96,7 +96,7 @@ def getTestDirs(base_path): def getTestNames(path): files = os.listdir(path) - files = [ f[:-3] for f in files if f.startswith("test") and f.endswith(".py") ] + files = [f[:-3] for f in files if f.startswith("test") and f.endswith(".py")] files.sort() return files @@ -137,14 +137,14 @@ class TextTestResult(_TextTestResult): self.portage_skipped = [] def addTodo(self, test, info): - self.todoed.append((test,info)) + self.todoed.append((test, info)) if self.showAll: self.stream.writeln("TODO") elif self.dots: self.stream.write(".") def addPortageSkip(self, test, info): - self.portage_skipped.append((test,info)) + self.portage_skipped.append((test, info)) if self.showAll: self.stream.writeln("SKIP") elif self.dots: @@ -200,7 +200,7 @@ class TestCase(unittest.TestCase): result.addPortageSkip(self, "%s: SKIP: %s" % (testMethod, self.portage_skip)) elif self.todo: - result.addTodo(self,"%s: TODO" % testMethod) + result.addTodo(self, "%s: TODO" % testMethod) else: result.addFailure(self, sys.exc_info()) except (KeyboardInterrupt, SystemExit): @@ -233,7 +233,7 @@ class TestCase(unittest.TestCase): except excClass: return else: - if hasattr(excClass,'__name__'): excName = excClass.__name__ + if hasattr(excClass, '__name__'): excName = excClass.__name__ else: excName = str(excClass) raise self.failureException("%s not raised: %s" % (excName, msg)) @@ -274,8 +274,8 @@ class TextTestRunner(unittest.TextTestRunner): self.stream.writeln("OK") return result -test_cps = ['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'), ('foo?', '!bar?') ] +test_cps = ['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'), ('foo?', '!bar?')] diff --git a/pym/portage/tests/bin/setup_env.py b/pym/portage/tests/bin/setup_env.py index 42a0e5676..9cc26df08 100644 --- a/pym/portage/tests/bin/setup_env.py +++ b/pym/portage/tests/bin/setup_env.py @@ -28,20 +28,20 @@ def binTestsInit(): global basedir, env basedir = tempfile.mkdtemp() env = {} - env["EAPI"] = "0" - env["D"] = os.path.join(basedir, "image") - env["T"] = os.path.join(basedir, "temp") - env["S"] = os.path.join(basedir, "workdir") - env["PF"] = "portage-tests-0.09-r1" - env["PATH"] = bindir + ":" + os.environ["PATH"] - env["PORTAGE_BIN_PATH"] = bindir - env["PORTAGE_PYM_PATH"] = PORTAGE_PYM_PATH - env["PORTAGE_INST_UID"] = str(os.getuid()) - env["PORTAGE_INST_GID"] = str(os.getgid()) - env["DESTTREE"] = "/usr" - os.mkdir(env["D"]) - os.mkdir(env["T"]) - os.mkdir(env["S"]) + env['EAPI'] = '0' + env['D'] = os.path.join(basedir, 'image') + env['T'] = os.path.join(basedir, 'temp') + env['S'] = os.path.join(basedir, 'workdir') + env['PF'] = 'portage-tests-0.09-r1' + env['PATH'] = bindir + ':' + os.environ['PATH'] + env['PORTAGE_BIN_PATH'] = bindir + env['PORTAGE_PYM_PATH'] = PORTAGE_PYM_PATH + env['PORTAGE_INST_UID'] = str(os.getuid()) + env['PORTAGE_INST_GID'] = str(os.getgid()) + env['DESTTREE'] = '/usr' + os.mkdir(env['D']) + os.mkdir(env['T']) + os.mkdir(env['S']) class BinTestCase(TestCase): def init(self): @@ -51,7 +51,7 @@ class BinTestCase(TestCase): def _exists_in_D(path): # Note: do not use os.path.join() here, we assume D to end in / - return os.access(env["D"] + path, os.W_OK) + return os.access(env['D'] + path, os.W_OK) def exists_in_D(path): if not _exists_in_D(path): raise TestCase.failureException @@ -66,7 +66,7 @@ def portage_func(func, args, exit_status=0): f = open('/dev/null', 'wb') fd_pipes = {0:0,1:f.fileno(),2:f.fileno()} def pre_exec(): - os.chdir(env["S"]) + os.chdir(env['S']) spawn([func] + args.split(), env=env, fd_pipes=fd_pipes, pre_exec=pre_exec) f.close() @@ -78,10 +78,10 @@ def create_portage_wrapper(bin): return portage_func(*newargs) return derived_func -for bin in os.listdir(os.path.join(bindir, "ebuild-helpers")): - if bin.startswith("do") or \ - bin.startswith("new") or \ - bin.startswith("prep") or \ - bin in ["ecompress","ecompressdir","fowners","fperms"]: +for bin in os.listdir(os.path.join(bindir, 'ebuild-helpers')): + if bin.startswith('do') or \ + bin.startswith('new') or \ + bin.startswith('prep') or \ + bin in ('ecompress', 'ecompressdir', 'fowners', 'fperms'): globals()[bin] = create_portage_wrapper( - os.path.join(bindir, "ebuild-helpers", bin)) + os.path.join(bindir, 'ebuild-helpers', bin)) diff --git a/pym/portage/tests/dep/testAtom.py b/pym/portage/tests/dep/testAtom.py index 948166d8e..da58be27c 100644 --- a/pym/portage/tests/dep/testAtom.py +++ b/pym/portage/tests/dep/testAtom.py @@ -10,146 +10,146 @@ class TestAtom(TestCase): def testAtom(self): tests = ( - ( "=sys-apps/portage-2.1-r1:0[doc,a=,!b=,c?,!d?,-e]", - ('=', 'sys-apps/portage', '2.1-r1', '0', '[doc,a=,!b=,c?,!d?,-e]', None), False, False ), - ( "=sys-apps/portage-2.1-r1*:0[doc]", - ('=*', 'sys-apps/portage', '2.1-r1', '0', '[doc]', None), False, False ), - ( "sys-apps/portage:0[doc]", - (None, 'sys-apps/portage', None, '0', '[doc]', None), False, False ), - ( "sys-apps/portage:0[doc]", - (None, 'sys-apps/portage', None, '0', '[doc]', None), False, False ), - ( "*/*", - (None, '*/*', None, None, None, None), True, False ), - ( "=*/*-*9999*", - ('=*', '*/*', '*9999*', None, None, None), True, False ), - ( "=*/*-*9999*:0::repo_name", - ('=*', '*/*', '*9999*', '0', None, 'repo_name'), True, True ), - ( "=*/*-*_beta*", - ('=*', '*/*', '*_beta*', None, None, None), True, False ), - ( "=*/*-*_beta*:0::repo_name", - ('=*', '*/*', '*_beta*', '0', None, 'repo_name'), True, True ), - ( "sys-apps/*", - (None, 'sys-apps/*', None, None, None, None), True, False ), - ( "*/portage", - (None, '*/portage', None, None, None, None), True, False ), - ( "s*s-*/portage:1", - (None, 's*s-*/portage', None, '1', None, None), True, False ), - ( "*/po*ge:2", - (None, '*/po*ge', None, '2', None, None), True, False ), - ( "!dev-libs/A", - (None, 'dev-libs/A', None, None, None, None), True, True ), - ( "!!dev-libs/A", - (None, 'dev-libs/A', None, None, None, None), True, True ), - ( "!!dev-libs/A", - (None, 'dev-libs/A', None, None, None, None), True, True ), - ( "dev-libs/A[foo(+)]", - (None, 'dev-libs/A', None, None, "[foo(+)]", None), True, True ), - ( "dev-libs/A[a(+),b(-)=,!c(+)=,d(-)?,!e(+)?,-f(-)]", - (None, 'dev-libs/A', None, None, "[a(+),b(-)=,!c(+)=,d(-)?,!e(+)?,-f(-)]", None), True, True ), - ( "dev-libs/A:2[a(+),b(-)=,!c(+)=,d(-)?,!e(+)?,-f(-)]", - (None, 'dev-libs/A', None, "2", "[a(+),b(-)=,!c(+)=,d(-)?,!e(+)?,-f(-)]", None), True, True ), - - ( "=sys-apps/portage-2.1-r1:0::repo_name[doc,a=,!b=,c?,!d?,-e]", - ('=', 'sys-apps/portage', '2.1-r1', '0', '[doc,a=,!b=,c?,!d?,-e]', 'repo_name'), False, True ), - ( "=sys-apps/portage-2.1-r1*:0::repo_name[doc]", - ('=*', 'sys-apps/portage', '2.1-r1', '0', '[doc]', 'repo_name'), False, True ), - ( "sys-apps/portage:0::repo_name[doc]", - (None, 'sys-apps/portage', None, '0', '[doc]', 'repo_name'), False, True ), - - ( "*/*::repo_name", - (None, '*/*', None, None, None, 'repo_name'), True, True ), - ( "sys-apps/*::repo_name", - (None, 'sys-apps/*', None, None, None, 'repo_name'), True, True ), - ( "*/portage::repo_name", - (None, '*/portage', None, None, None, 'repo_name'), True, True ), - ( "s*s-*/portage:1::repo_name", - (None, 's*s-*/portage', None, '1', None, 'repo_name'), True, True ), + ("=sys-apps/portage-2.1-r1:0[doc,a=,!b=,c?,!d?,-e]", + ('=', 'sys-apps/portage', '2.1-r1', '0', '[doc,a=,!b=,c?,!d?,-e]', None), False, False), + ("=sys-apps/portage-2.1-r1*:0[doc]", + ('=*', 'sys-apps/portage', '2.1-r1', '0', '[doc]', None), False, False), + ("sys-apps/portage:0[doc]", + (None, 'sys-apps/portage', None, '0', '[doc]', None), False, False), + ("sys-apps/portage:0[doc]", + (None, 'sys-apps/portage', None, '0', '[doc]', None), False, False), + ("*/*", + (None, '*/*', None, None, None, None), True, False), + ("=*/*-*9999*", + ('=*', '*/*', '*9999*', None, None, None), True, False), + ("=*/*-*9999*:0::repo_name", + ('=*', '*/*', '*9999*', '0', None, 'repo_name'), True, True), + ("=*/*-*_beta*", + ('=*', '*/*', '*_beta*', None, None, None), True, False), + ("=*/*-*_beta*:0::repo_name", + ('=*', '*/*', '*_beta*', '0', None, 'repo_name'), True, True), + ("sys-apps/*", + (None, 'sys-apps/*', None, None, None, None), True, False), + ("*/portage", + (None, '*/portage', None, None, None, None), True, False), + ("s*s-*/portage:1", + (None, 's*s-*/portage', None, '1', None, None), True, False), + ("*/po*ge:2", + (None, '*/po*ge', None, '2', None, None), True, False), + ("!dev-libs/A", + (None, 'dev-libs/A', None, None, None, None), True, True), + ("!!dev-libs/A", + (None, 'dev-libs/A', None, None, None, None), True, True), + ("!!dev-libs/A", + (None, 'dev-libs/A', None, None, None, None), True, True), + ("dev-libs/A[foo(+)]", + (None, 'dev-libs/A', None, None, "[foo(+)]", None), True, True), + ("dev-libs/A[a(+),b(-)=,!c(+)=,d(-)?,!e(+)?,-f(-)]", + (None, 'dev-libs/A', None, None, "[a(+),b(-)=,!c(+)=,d(-)?,!e(+)?,-f(-)]", None), True, True), + ("dev-libs/A:2[a(+),b(-)=,!c(+)=,d(-)?,!e(+)?,-f(-)]", + (None, 'dev-libs/A', None, "2", "[a(+),b(-)=,!c(+)=,d(-)?,!e(+)?,-f(-)]", None), True, True), + + ("=sys-apps/portage-2.1-r1:0::repo_name[doc,a=,!b=,c?,!d?,-e]", + ('=', 'sys-apps/portage', '2.1-r1', '0', '[doc,a=,!b=,c?,!d?,-e]', 'repo_name'), False, True), + ("=sys-apps/portage-2.1-r1*:0::repo_name[doc]", + ('=*', 'sys-apps/portage', '2.1-r1', '0', '[doc]', 'repo_name'), False, True), + ("sys-apps/portage:0::repo_name[doc]", + (None, 'sys-apps/portage', None, '0', '[doc]', 'repo_name'), False, True), + + ("*/*::repo_name", + (None, '*/*', None, None, None, 'repo_name'), True, True), + ("sys-apps/*::repo_name", + (None, 'sys-apps/*', None, None, None, 'repo_name'), True, True), + ("*/portage::repo_name", + (None, '*/portage', None, None, None, 'repo_name'), True, True), + ("s*s-*/portage:1::repo_name", + (None, 's*s-*/portage', None, '1', None, 'repo_name'), True, True), ) - + tests_xfail = ( - ( Atom("sys-apps/portage"), False, False ), - ( "cat/pkg[a!]", False, False ), - ( "cat/pkg[!a]", False, False ), - ( "cat/pkg[!a!]", False, False ), - ( "cat/pkg[!a-]", False, False ), - ( "cat/pkg[-a=]", False, False ), - ( "cat/pkg[-a?]", False, False ), - ( "cat/pkg[-a!]", False, False ), - ( "cat/pkg[=a]", False, False ), - ( "cat/pkg[=a=]", False, False ), - ( "cat/pkg[=a?]", False, False ), - ( "cat/pkg[=a!]", False, False ), - ( "cat/pkg[=a-]", False, False ), - ( "cat/pkg[?a]", False, False ), - ( "cat/pkg[?a=]", False, False ), - ( "cat/pkg[?a?]", False, False ), - ( "cat/pkg[?a!]", False, False ), - ( "cat/pkg[?a-]", False, False ), - ( "sys-apps/portage[doc]:0", False, False ), - ( "*/*", False, False ), - ( "sys-apps/*", False, False ), - ( "*/portage", False, False ), - ( "*/**", True, False ), - ( "*/portage[use]", True, False ), - ( "cat/pkg[a()]", False, False ), - ( "cat/pkg[a(]", False, False ), - ( "cat/pkg[a)]", False, False ), - ( "cat/pkg[a(,b]", False, False ), - ( "cat/pkg[a),b]", False, False ), - ( "cat/pkg[a(*)]", False, False ), - ( "cat/pkg[a(*)]", True, False ), - ( "cat/pkg[a(+-)]", False, False ), - ( "cat/pkg[a()]", False, False ), - ( "cat/pkg[(+)a]", False, False ), - ( "cat/pkg[a=(+)]", False, False ), - ( "cat/pkg[!(+)a=]", False, False ), - ( "cat/pkg[!a=(+)]", False, False ), - ( "cat/pkg[a?(+)]", False, False ), - ( "cat/pkg[!a?(+)]", False, False ), - ( "cat/pkg[!(+)a?]", False, False ), - ( "cat/pkg[-(+)a]", False, False ), - ( "cat/pkg[a(+),-a]", False, False ), - ( "cat/pkg[a(-),-a]", False, False ), - ( "cat/pkg[-a,a(+)]", False, False ), - ( "cat/pkg[-a,a(-)]", False, False ), - ( "cat/pkg[-a(+),a(-)]", False, False ), - ( "cat/pkg[-a(-),a(+)]", False, False ), - ( "sys-apps/portage[doc]::repo_name", False, False ), - ( "sys-apps/portage:0[doc]::repo_name", False, False ), - ( "sys-apps/portage[doc]:0::repo_name", False, False ), - ( "=sys-apps/portage-2.1-r1:0::repo_name[doc,a=,!b=,c?,!d?,-e]", False, False ), - ( "=sys-apps/portage-2.1-r1*:0::repo_name[doc]", False, False ), - ( "sys-apps/portage:0::repo_name[doc]", False, False ), - ( "*/*::repo_name", True, False ), + (Atom("sys-apps/portage"), False, False), + ("cat/pkg[a!]", False, False), + ("cat/pkg[!a]", False, False), + ("cat/pkg[!a!]", False, False), + ("cat/pkg[!a-]", False, False), + ("cat/pkg[-a=]", False, False), + ("cat/pkg[-a?]", False, False), + ("cat/pkg[-a!]", False, False), + ("cat/pkg[=a]", False, False), + ("cat/pkg[=a=]", False, False), + ("cat/pkg[=a?]", False, False), + ("cat/pkg[=a!]", False, False), + ("cat/pkg[=a-]", False, False), + ("cat/pkg[?a]", False, False), + ("cat/pkg[?a=]", False, False), + ("cat/pkg[?a?]", False, False), + ("cat/pkg[?a!]", False, False), + ("cat/pkg[?a-]", False, False), + ("sys-apps/portage[doc]:0", False, False), + ("*/*", False, False), + ("sys-apps/*", False, False), + ("*/portage", False, False), + ("*/**", True, False), + ("*/portage[use]", True, False), + ("cat/pkg[a()]", False, False), + ("cat/pkg[a(]", False, False), + ("cat/pkg[a)]", False, False), + ("cat/pkg[a(,b]", False, False), + ("cat/pkg[a),b]", False, False), + ("cat/pkg[a(*)]", False, False), + ("cat/pkg[a(*)]", True, False), + ("cat/pkg[a(+-)]", False, False), + ("cat/pkg[a()]", False, False), + ("cat/pkg[(+)a]", False, False), + ("cat/pkg[a=(+)]", False, False), + ("cat/pkg[!(+)a=]", False, False), + ("cat/pkg[!a=(+)]", False, False), + ("cat/pkg[a?(+)]", False, False), + ("cat/pkg[!a?(+)]", False, False), + ("cat/pkg[!(+)a?]", False, False), + ("cat/pkg[-(+)a]", False, False), + ("cat/pkg[a(+),-a]", False, False), + ("cat/pkg[a(-),-a]", False, False), + ("cat/pkg[-a,a(+)]", False, False), + ("cat/pkg[-a,a(-)]", False, False), + ("cat/pkg[-a(+),a(-)]", False, False), + ("cat/pkg[-a(-),a(+)]", False, False), + ("sys-apps/portage[doc]::repo_name", False, False), + ("sys-apps/portage:0[doc]::repo_name", False, False), + ("sys-apps/portage[doc]:0::repo_name", False, False), + ("=sys-apps/portage-2.1-r1:0::repo_name[doc,a=,!b=,c?,!d?,-e]", False, False), + ("=sys-apps/portage-2.1-r1*:0::repo_name[doc]", False, False), + ("sys-apps/portage:0::repo_name[doc]", False, False), + ("*/*::repo_name", True, False), ) for atom, parts, allow_wildcard, allow_repo in tests: a = Atom(atom, allow_wildcard=allow_wildcard, allow_repo=allow_repo) op, cp, ver, slot, use, repo = parts - self.assertEqual( op, a.operator, - msg="Atom('%s').operator = %s == '%s'" % ( atom, a.operator, op ) ) - self.assertEqual( cp, a.cp, - msg="Atom('%s').cp = %s == '%s'" % ( atom, a.cp, cp ) ) + self.assertEqual(op, a.operator, + msg="Atom('%s').operator = %s == '%s'" % (atom, a.operator, op)) + self.assertEqual(cp, a.cp, + msg="Atom('%s').cp = %s == '%s'" % (atom, a.cp, cp)) if ver is not None: cpv = "%s-%s" % (cp, ver) else: cpv = cp - self.assertEqual( cpv, a.cpv, - msg="Atom('%s').cpv = %s == '%s'" % ( atom, a.cpv, cpv ) ) - self.assertEqual( slot, a.slot, - msg="Atom('%s').slot = %s == '%s'" % ( atom, a.slot, slot ) ) - self.assertEqual( repo, a.repo, - msg="Atom('%s').repo == %s == '%s'" % ( atom, a.repo, repo ) ) + self.assertEqual(cpv, a.cpv, + msg="Atom('%s').cpv = %s == '%s'" % (atom, a.cpv, cpv)) + self.assertEqual(slot, a.slot, + msg="Atom('%s').slot = %s == '%s'" % (atom, a.slot, slot)) + self.assertEqual(repo, a.repo, + msg="Atom('%s').repo == %s == '%s'" % (atom, a.repo, repo)) if a.use: returned_use = str(a.use) else: returned_use = None - self.assertEqual( use, returned_use, - msg="Atom('%s').use = %s == '%s'" % ( atom, returned_use, use ) ) + self.assertEqual(use, returned_use, + msg="Atom('%s').use = %s == '%s'" % (atom, returned_use, use)) for atom, allow_wildcard, allow_repo in tests_xfail: - self.assertRaisesMsg(atom, (InvalidAtom, TypeError), Atom, atom, \ + self.assertRaisesMsg(atom, (InvalidAtom, TypeError), Atom, atom, allow_wildcard=allow_wildcard, allow_repo=allow_repo) def testSlotAbiAtom(self): @@ -168,7 +168,7 @@ class TestAtom(TestCase): for k, v in parts.items(): self.assertEqual(v, getattr(a, k), msg="Atom('%s').%s = %s == '%s'" % - (atom, k, getattr(a, k), v )) + (atom, k, getattr(a, k), v)) def test_intersects(self): test_cases = ( @@ -185,7 +185,7 @@ class TestAtom(TestCase): ) for atom, other, expected_result in test_cases: - self.assertEqual(Atom(atom).intersects(Atom(other)), expected_result, \ + self.assertEqual(Atom(atom).intersects(Atom(other)), expected_result, "%s and %s should intersect: %s" % (atom, other, expected_result)) def test_violated_conditionals(self): @@ -279,7 +279,7 @@ class TestAtom(TestCase): for atom, other_use, iuse, parent_use in test_cases_xfail: a = Atom(atom) validator = use_flag_validator(iuse) - self.assertRaisesMsg(atom, InvalidAtom, \ + self.assertRaisesMsg(atom, InvalidAtom, a.violated_conditionals, other_use, validator.is_valid_flag, parent_use) def test_evaluate_conditionals(self): @@ -328,9 +328,9 @@ class TestAtom(TestCase): ("dev-libs/A[a,b=,!c=,d?,!e?,-f]", ["d", "e", "f"], [], "dev-libs/A[a,b,-b,c,-c,-e,-f]"), ("dev-libs/A[a,b=,!c=,d?,!e?,-f]", [], ["d", "e", "f"], "dev-libs/A[a,b,-b,c,-c,d,-f]"), - ("dev-libs/A[a(-),b(+)=,!c(-)=,d(+)?,!e(-)?,-f(+)]", \ + ("dev-libs/A[a(-),b(+)=,!c(-)=,d(+)?,!e(-)?,-f(+)]", ["a", "b", "c", "d", "e", "f"], [], "dev-libs/A[a(-),-b(+),c(-),-e(-),-f(+)]"), - ("dev-libs/A[a(+),b(-)=,!c(+)=,d(-)?,!e(+)?,-f(-)]", \ + ("dev-libs/A[a(+),b(-)=,!c(+)=,d(-)?,!e(+)?,-f(-)]", [], ["a", "b", "c", "d", "e", "f"], "dev-libs/A[a(+),b(-),-c(+),d(-),-f(-)]"), ) diff --git a/pym/portage/tests/dep/testCheckRequiredUse.py b/pym/portage/tests/dep/testCheckRequiredUse.py index d85ad92d3..63330b5cb 100644 --- a/pym/portage/tests/dep/testCheckRequiredUse.py +++ b/pym/portage/tests/dep/testCheckRequiredUse.py @@ -9,106 +9,106 @@ class TestCheckRequiredUse(TestCase): def testCheckRequiredUse(self): test_cases = ( - ( "|| ( a b )", [], ["a", "b"], False), - ( "|| ( a b )", ["a"], ["a", "b"], True), - ( "|| ( a b )", ["b"], ["a", "b"], True), - ( "|| ( a b )", ["a", "b"], ["a", "b"], True), - - ( "^^ ( a b )", [], ["a", "b"], False), - ( "^^ ( a b )", ["a"], ["a", "b"], True), - ( "^^ ( a b )", ["b"], ["a", "b"], True), - ( "^^ ( a b )", ["a", "b"], ["a", "b"], False), - ( "?? ( a b )", ["a", "b"], ["a", "b"], False), - ( "?? ( a b )", ["a"], ["a", "b"], True), - ( "?? ( a b )", ["b"], ["a", "b"], True), - ( "?? ( a b )", [], ["a", "b"], True), - ( "?? ( )", [], [], True), - - ( "^^ ( || ( a b ) c )", [], ["a", "b", "c"], False), - ( "^^ ( || ( a b ) c )", ["a"], ["a", "b", "c"], True), - - ( "^^ ( || ( ( a b ) ) ( c ) )", [], ["a", "b", "c"], False), - ( "( ^^ ( ( || ( ( a ) ( b ) ) ) ( ( c ) ) ) )", ["a"], ["a", "b", "c"], True), - - ( "a || ( b c )", ["a"], ["a", "b", "c"], False), - ( "|| ( b c ) a", ["a"], ["a", "b", "c"], False), - - ( "|| ( a b c )", ["a"], ["a", "b", "c"], True), - ( "|| ( a b c )", ["b"], ["a", "b", "c"], True), - ( "|| ( a b c )", ["c"], ["a", "b", "c"], True), - - ( "^^ ( a b c )", ["a"], ["a", "b", "c"], True), - ( "^^ ( a b c )", ["b"], ["a", "b", "c"], True), - ( "^^ ( a b c )", ["c"], ["a", "b", "c"], True), - ( "^^ ( a b c )", ["a", "b"], ["a", "b", "c"], False), - ( "^^ ( a b c )", ["b", "c"], ["a", "b", "c"], False), - ( "^^ ( a b c )", ["a", "c"], ["a", "b", "c"], False), - ( "^^ ( a b c )", ["a", "b", "c"], ["a", "b", "c"], False), - - ( "a? ( ^^ ( b c ) )", [], ["a", "b", "c"], True), - ( "a? ( ^^ ( b c ) )", ["a"], ["a", "b", "c"], False), - ( "a? ( ^^ ( b c ) )", ["b"], ["a", "b", "c"], True), - ( "a? ( ^^ ( b c ) )", ["c"], ["a", "b", "c"], True), - ( "a? ( ^^ ( b c ) )", ["a", "b"], ["a", "b", "c"], True), - ( "a? ( ^^ ( b c ) )", ["a", "b", "c"], ["a", "b", "c"], False), - - ( "^^ ( a? ( !b ) !c? ( d ) )", [], ["a", "b", "c", "d"], False), - ( "^^ ( a? ( !b ) !c? ( d ) )", ["a"], ["a", "b", "c", "d"], True), - ( "^^ ( a? ( !b ) !c? ( d ) )", ["c"], ["a", "b", "c", "d"], True), - ( "^^ ( a? ( !b ) !c? ( d ) )", ["a", "c"], ["a", "b", "c", "d"], True), - ( "^^ ( a? ( !b ) !c? ( d ) )", ["a", "b", "c"], ["a", "b", "c", "d"], False), - ( "^^ ( a? ( !b ) !c? ( d ) )", ["a", "b", "d"], ["a", "b", "c", "d"], True), - ( "^^ ( a? ( !b ) !c? ( d ) )", ["a", "b", "d"], ["a", "b", "c", "d"], True), - ( "^^ ( a? ( !b ) !c? ( d ) )", ["a", "d"], ["a", "b", "c", "d"], False), - - ( "|| ( ^^ ( a b ) ^^ ( b c ) )", [], ["a", "b", "c"], False), - ( "|| ( ^^ ( a b ) ^^ ( b c ) )", ["a"], ["a", "b", "c"], True), - ( "|| ( ^^ ( a b ) ^^ ( b c ) )", ["b"], ["a", "b", "c"], True), - ( "|| ( ^^ ( a b ) ^^ ( b c ) )", ["c"], ["a", "b", "c"], True), - ( "|| ( ^^ ( a b ) ^^ ( b c ) )", ["a", "b"], ["a", "b", "c"], True), - ( "|| ( ^^ ( a b ) ^^ ( b c ) )", ["a", "c"], ["a", "b", "c"], True), - ( "|| ( ^^ ( a b ) ^^ ( b c ) )", ["b", "c"], ["a", "b", "c"], True), - ( "|| ( ^^ ( a b ) ^^ ( b c ) )", ["a", "b", "c"], ["a", "b", "c"], False), - - ( "^^ ( || ( a b ) ^^ ( b c ) )", [], ["a", "b", "c"], False), - ( "^^ ( || ( a b ) ^^ ( b c ) )", ["a"], ["a", "b", "c"], True), - ( "^^ ( || ( a b ) ^^ ( b c ) )", ["b"], ["a", "b", "c"], False), - ( "^^ ( || ( a b ) ^^ ( b c ) )", ["c"], ["a", "b", "c"], True), - ( "^^ ( || ( a b ) ^^ ( b c ) )", ["a", "b"], ["a", "b", "c"], False), - ( "^^ ( || ( a b ) ^^ ( b c ) )", ["a", "c"], ["a", "b", "c"], False), - ( "^^ ( || ( a b ) ^^ ( b c ) )", ["b", "c"], ["a", "b", "c"], True), - ( "^^ ( || ( a b ) ^^ ( b c ) )", ["a", "b", "c"], ["a", "b", "c"], True), - - ( "|| ( ( a b ) c )", ["a", "b", "c"], ["a", "b", "c"], True), - ( "|| ( ( a b ) c )", ["b", "c"], ["a", "b", "c"], True), - ( "|| ( ( a b ) c )", ["a", "c"], ["a", "b", "c"], True), - ( "|| ( ( a b ) c )", ["a", "b"], ["a", "b", "c"], True), - ( "|| ( ( a b ) c )", ["a"], ["a", "b", "c"], False), - ( "|| ( ( a b ) c )", ["b"], ["a", "b", "c"], False), - ( "|| ( ( a b ) c )", ["c"], ["a", "b", "c"], True), - ( "|| ( ( a b ) c )", [], ["a", "b", "c"], False), - - ( "^^ ( ( a b ) c )", ["a", "b", "c"], ["a", "b", "c"], False), - ( "^^ ( ( a b ) c )", ["b", "c"], ["a", "b", "c"], True), - ( "^^ ( ( a b ) c )", ["a", "c"], ["a", "b", "c"], True), - ( "^^ ( ( a b ) c )", ["a", "b"], ["a", "b", "c"], True), - ( "^^ ( ( a b ) c )", ["a"], ["a", "b", "c"], False), - ( "^^ ( ( a b ) c )", ["b"], ["a", "b", "c"], False), - ( "^^ ( ( a b ) c )", ["c"], ["a", "b", "c"], True), - ( "^^ ( ( a b ) c )", [], ["a", "b", "c"], False), + ("|| ( a b )", [], ["a", "b"], False), + ("|| ( a b )", ["a"], ["a", "b"], True), + ("|| ( a b )", ["b"], ["a", "b"], True), + ("|| ( a b )", ["a", "b"], ["a", "b"], True), + + ("^^ ( a b )", [], ["a", "b"], False), + ("^^ ( a b )", ["a"], ["a", "b"], True), + ("^^ ( a b )", ["b"], ["a", "b"], True), + ("^^ ( a b )", ["a", "b"], ["a", "b"], False), + ("?? ( a b )", ["a", "b"], ["a", "b"], False), + ("?? ( a b )", ["a"], ["a", "b"], True), + ("?? ( a b )", ["b"], ["a", "b"], True), + ("?? ( a b )", [], ["a", "b"], True), + ("?? ( )", [], [], True), + + ("^^ ( || ( a b ) c )", [], ["a", "b", "c"], False), + ("^^ ( || ( a b ) c )", ["a"], ["a", "b", "c"], True), + + ("^^ ( || ( ( a b ) ) ( c ) )", [], ["a", "b", "c"], False), + ("( ^^ ( ( || ( ( a ) ( b ) ) ) ( ( c ) ) ) )", ["a"], ["a", "b", "c"], True), + + ("a || ( b c )", ["a"], ["a", "b", "c"], False), + ("|| ( b c ) a", ["a"], ["a", "b", "c"], False), + + ("|| ( a b c )", ["a"], ["a", "b", "c"], True), + ("|| ( a b c )", ["b"], ["a", "b", "c"], True), + ("|| ( a b c )", ["c"], ["a", "b", "c"], True), + + ("^^ ( a b c )", ["a"], ["a", "b", "c"], True), + ("^^ ( a b c )", ["b"], ["a", "b", "c"], True), + ("^^ ( a b c )", ["c"], ["a", "b", "c"], True), + ("^^ ( a b c )", ["a", "b"], ["a", "b", "c"], False), + ("^^ ( a b c )", ["b", "c"], ["a", "b", "c"], False), + ("^^ ( a b c )", ["a", "c"], ["a", "b", "c"], False), + ("^^ ( a b c )", ["a", "b", "c"], ["a", "b", "c"], False), + + ("a? ( ^^ ( b c ) )", [], ["a", "b", "c"], True), + ("a? ( ^^ ( b c ) )", ["a"], ["a", "b", "c"], False), + ("a? ( ^^ ( b c ) )", ["b"], ["a", "b", "c"], True), + ("a? ( ^^ ( b c ) )", ["c"], ["a", "b", "c"], True), + ("a? ( ^^ ( b c ) )", ["a", "b"], ["a", "b", "c"], True), + ("a? ( ^^ ( b c ) )", ["a", "b", "c"], ["a", "b", "c"], False), + + ("^^ ( a? ( !b ) !c? ( d ) )", [], ["a", "b", "c", "d"], False), + ("^^ ( a? ( !b ) !c? ( d ) )", ["a"], ["a", "b", "c", "d"], True), + ("^^ ( a? ( !b ) !c? ( d ) )", ["c"], ["a", "b", "c", "d"], True), + ("^^ ( a? ( !b ) !c? ( d ) )", ["a", "c"], ["a", "b", "c", "d"], True), + ("^^ ( a? ( !b ) !c? ( d ) )", ["a", "b", "c"], ["a", "b", "c", "d"], False), + ("^^ ( a? ( !b ) !c? ( d ) )", ["a", "b", "d"], ["a", "b", "c", "d"], True), + ("^^ ( a? ( !b ) !c? ( d ) )", ["a", "b", "d"], ["a", "b", "c", "d"], True), + ("^^ ( a? ( !b ) !c? ( d ) )", ["a", "d"], ["a", "b", "c", "d"], False), + + ("|| ( ^^ ( a b ) ^^ ( b c ) )", [], ["a", "b", "c"], False), + ("|| ( ^^ ( a b ) ^^ ( b c ) )", ["a"], ["a", "b", "c"], True), + ("|| ( ^^ ( a b ) ^^ ( b c ) )", ["b"], ["a", "b", "c"], True), + ("|| ( ^^ ( a b ) ^^ ( b c ) )", ["c"], ["a", "b", "c"], True), + ("|| ( ^^ ( a b ) ^^ ( b c ) )", ["a", "b"], ["a", "b", "c"], True), + ("|| ( ^^ ( a b ) ^^ ( b c ) )", ["a", "c"], ["a", "b", "c"], True), + ("|| ( ^^ ( a b ) ^^ ( b c ) )", ["b", "c"], ["a", "b", "c"], True), + ("|| ( ^^ ( a b ) ^^ ( b c ) )", ["a", "b", "c"], ["a", "b", "c"], False), + + ("^^ ( || ( a b ) ^^ ( b c ) )", [], ["a", "b", "c"], False), + ("^^ ( || ( a b ) ^^ ( b c ) )", ["a"], ["a", "b", "c"], True), + ("^^ ( || ( a b ) ^^ ( b c ) )", ["b"], ["a", "b", "c"], False), + ("^^ ( || ( a b ) ^^ ( b c ) )", ["c"], ["a", "b", "c"], True), + ("^^ ( || ( a b ) ^^ ( b c ) )", ["a", "b"], ["a", "b", "c"], False), + ("^^ ( || ( a b ) ^^ ( b c ) )", ["a", "c"], ["a", "b", "c"], False), + ("^^ ( || ( a b ) ^^ ( b c ) )", ["b", "c"], ["a", "b", "c"], True), + ("^^ ( || ( a b ) ^^ ( b c ) )", ["a", "b", "c"], ["a", "b", "c"], True), + + ("|| ( ( a b ) c )", ["a", "b", "c"], ["a", "b", "c"], True), + ("|| ( ( a b ) c )", ["b", "c"], ["a", "b", "c"], True), + ("|| ( ( a b ) c )", ["a", "c"], ["a", "b", "c"], True), + ("|| ( ( a b ) c )", ["a", "b"], ["a", "b", "c"], True), + ("|| ( ( a b ) c )", ["a"], ["a", "b", "c"], False), + ("|| ( ( a b ) c )", ["b"], ["a", "b", "c"], False), + ("|| ( ( a b ) c )", ["c"], ["a", "b", "c"], True), + ("|| ( ( a b ) c )", [], ["a", "b", "c"], False), + + ("^^ ( ( a b ) c )", ["a", "b", "c"], ["a", "b", "c"], False), + ("^^ ( ( a b ) c )", ["b", "c"], ["a", "b", "c"], True), + ("^^ ( ( a b ) c )", ["a", "c"], ["a", "b", "c"], True), + ("^^ ( ( a b ) c )", ["a", "b"], ["a", "b", "c"], True), + ("^^ ( ( a b ) c )", ["a"], ["a", "b", "c"], False), + ("^^ ( ( a b ) c )", ["b"], ["a", "b", "c"], False), + ("^^ ( ( a b ) c )", ["c"], ["a", "b", "c"], True), + ("^^ ( ( a b ) c )", [], ["a", "b", "c"], False), ) test_cases_xfail = ( - ( "^^ ( || ( a b ) ^^ ( b c ) )", [], ["a", "b"]), - ( "^^ ( || ( a b ) ^^ ( b c )", [], ["a", "b", "c"]), - ( "^^( || ( a b ) ^^ ( b c ) )", [], ["a", "b", "c"]), - ( "^^ || ( a b ) ^^ ( b c )", [], ["a", "b", "c"]), - ( "^^ ( ( || ) ( a b ) ^^ ( b c ) )", [], ["a", "b", "c"]), - ( "^^ ( || ( a b ) ) ^^ ( b c ) )", [], ["a", "b", "c"]), + ("^^ ( || ( a b ) ^^ ( b c ) )", [], ["a", "b"]), + ("^^ ( || ( a b ) ^^ ( b c )", [], ["a", "b", "c"]), + ("^^( || ( a b ) ^^ ( b c ) )", [], ["a", "b", "c"]), + ("^^ || ( a b ) ^^ ( b c )", [], ["a", "b", "c"]), + ("^^ ( ( || ) ( a b ) ^^ ( b c ) )", [], ["a", "b", "c"]), + ("^^ ( || ( a b ) ) ^^ ( b c ) )", [], ["a", "b", "c"]), ) test_cases_xfail_eapi = ( - ( "?? ( a b )", [], ["a", "b"], "4"), + ("?? ( a b )", [], ["a", "b"], "4"), ) for required_use, use, iuse, expected in test_cases: diff --git a/pym/portage/tests/dep/testStandalone.py b/pym/portage/tests/dep/testStandalone.py index f03f2d508..88e3f39f8 100644 --- a/pym/portage/tests/dep/testStandalone.py +++ b/pym/portage/tests/dep/testStandalone.py @@ -12,20 +12,20 @@ class TestStandalone(TestCase): def testCPVequal(self): test_cases = ( - ( "sys-apps/portage-2.1","sys-apps/portage-2.1", True ), - ( "sys-apps/portage-2.1","sys-apps/portage-2.0", False ), - ( "sys-apps/portage-2.1","sys-apps/portage-2.1-r1", False ), - ( "sys-apps/portage-2.1-r1","sys-apps/portage-2.1", False ), - ( "sys-apps/portage-2.1_alpha3","sys-apps/portage-2.1", False ), - ( "sys-apps/portage-2.1_alpha3_p6","sys-apps/portage-2.1_alpha3", False ), - ( "sys-apps/portage-2.1_alpha3","sys-apps/portage-2.1", False ), - ( "sys-apps/portage-2.1","sys-apps/X-2.1", False ), - ( "sys-apps/portage-2.1","portage-2.1", False ), + ("sys-apps/portage-2.1", "sys-apps/portage-2.1", True), + ("sys-apps/portage-2.1", "sys-apps/portage-2.0", False), + ("sys-apps/portage-2.1", "sys-apps/portage-2.1-r1", False), + ("sys-apps/portage-2.1-r1", "sys-apps/portage-2.1", False), + ("sys-apps/portage-2.1_alpha3", "sys-apps/portage-2.1", False), + ("sys-apps/portage-2.1_alpha3_p6", "sys-apps/portage-2.1_alpha3", False), + ("sys-apps/portage-2.1_alpha3", "sys-apps/portage-2.1", False), + ("sys-apps/portage-2.1", "sys-apps/X-2.1", False), + ("sys-apps/portage-2.1", "portage-2.1", False), ) - + test_cases_xfail = ( - ( "sys-apps/portage","sys-apps/portage" ), - ( "sys-apps/portage-2.1-6","sys-apps/portage-2.1-6" ), + ("sys-apps/portage", "sys-apps/portage"), + ("sys-apps/portage-2.1-6", "sys-apps/portage-2.1-6"), ) for cpv1, cpv2, expected_result in test_cases: @@ -33,5 +33,5 @@ class TestStandalone(TestCase): "cpvequal('%s', '%s') != %s" % (cpv1, cpv2, expected_result)) for cpv1, cpv2 in test_cases_xfail: - self.assertRaisesMsg("cpvequal("+cpv1+", "+cpv2+")", \ + self.assertRaisesMsg("cpvequal(%s, %s)" % (cpv1, cpv2), PortageException, cpvequal, cpv1, cpv2) diff --git a/pym/portage/tests/dep/test_best_match_to_list.py b/pym/portage/tests/dep/test_best_match_to_list.py index 0ea834238..586c8bc50 100644 --- a/pym/portage/tests/dep/test_best_match_to_list.py +++ b/pym/portage/tests/dep/test_best_match_to_list.py @@ -28,29 +28,29 @@ class Test_best_match_to_list(TestCase): def testBest_match_to_list(self): tests = [ - ("dev-libs/A-4", [Atom(">=dev-libs/A-3"), Atom(">=dev-libs/A-2")], \ - [Atom(">=dev-libs/A-3"), Atom(">=dev-libs/A-2")], True), - ("dev-libs/A-4", [Atom("<=dev-libs/A-5"), Atom("<=dev-libs/A-6")], \ - [Atom("<=dev-libs/A-5"), Atom("<=dev-libs/A-6")], True), - ("dev-libs/A-1", [Atom("dev-libs/A"), Atom("=dev-libs/A-1")], \ - [Atom("=dev-libs/A-1"), Atom("dev-libs/A")], True), - ("dev-libs/A-1", [Atom("dev-libs/B"), Atom("=dev-libs/A-1:0")], \ - [Atom("=dev-libs/A-1:0")], True), - ("dev-libs/A-1", [Atom("dev-libs/*", allow_wildcard=True), Atom("=dev-libs/A-1:0")], \ - [Atom("=dev-libs/A-1:0"), Atom("dev-libs/*", allow_wildcard=True)], True), - ("dev-libs/A-4.9999-r1", [Atom("dev-libs/*", allow_wildcard=True), Atom("=*/*-*9999*", allow_wildcard=True)], \ - [Atom("=*/*-*9999*", allow_wildcard=True), Atom("dev-libs/*", allow_wildcard=True)], True), - ("dev-libs/A-4_beta-r1", [Atom("dev-libs/*", allow_wildcard=True), Atom("=*/*-*_beta*", allow_wildcard=True)], \ - [Atom("=*/*-*_beta*", allow_wildcard=True), Atom("dev-libs/*", allow_wildcard=True)], True), - ("dev-libs/A-4_beta1-r1", [Atom("dev-libs/*", allow_wildcard=True), Atom("=*/*-*_beta*", allow_wildcard=True)], \ - [Atom("=*/*-*_beta*", allow_wildcard=True), Atom("dev-libs/*", allow_wildcard=True)], True), - ("dev-libs/A-1:0", [Atom("dev-*/*", allow_wildcard=True), Atom("dev-*/*:0", allow_wildcard=True),\ - Atom("dev-libs/A"), Atom("<=dev-libs/A-2"), Atom("dev-libs/A:0"), \ - Atom("=dev-libs/A-1*"), Atom("~dev-libs/A-1"), Atom("=dev-libs/A-1")], \ - [Atom("=dev-libs/A-1"), Atom("~dev-libs/A-1"), Atom("=dev-libs/A-1*"), \ - Atom("dev-libs/A:0"), Atom("<=dev-libs/A-2"), Atom("dev-libs/A"), \ - Atom("dev-*/*:0", allow_wildcard=True), Atom("dev-*/*", allow_wildcard=True)], False) - ] + ("dev-libs/A-4", [Atom(">=dev-libs/A-3"), Atom(">=dev-libs/A-2")], + [Atom(">=dev-libs/A-3"), Atom(">=dev-libs/A-2")], True), + ("dev-libs/A-4", [Atom("<=dev-libs/A-5"), Atom("<=dev-libs/A-6")], + [Atom("<=dev-libs/A-5"), Atom("<=dev-libs/A-6")], True), + ("dev-libs/A-1", [Atom("dev-libs/A"), Atom("=dev-libs/A-1")], + [Atom("=dev-libs/A-1"), Atom("dev-libs/A")], True), + ("dev-libs/A-1", [Atom("dev-libs/B"), Atom("=dev-libs/A-1:0")], + [Atom("=dev-libs/A-1:0")], True), + ("dev-libs/A-1", [Atom("dev-libs/*", allow_wildcard=True), Atom("=dev-libs/A-1:0")], + [Atom("=dev-libs/A-1:0"), Atom("dev-libs/*", allow_wildcard=True)], True), + ("dev-libs/A-4.9999-r1", [Atom("dev-libs/*", allow_wildcard=True), Atom("=*/*-*9999*", allow_wildcard=True)], + [Atom("=*/*-*9999*", allow_wildcard=True), Atom("dev-libs/*", allow_wildcard=True)], True), + ("dev-libs/A-4_beta-r1", [Atom("dev-libs/*", allow_wildcard=True), Atom("=*/*-*_beta*", allow_wildcard=True)], + [Atom("=*/*-*_beta*", allow_wildcard=True), Atom("dev-libs/*", allow_wildcard=True)], True), + ("dev-libs/A-4_beta1-r1", [Atom("dev-libs/*", allow_wildcard=True), Atom("=*/*-*_beta*", allow_wildcard=True)], + [Atom("=*/*-*_beta*", allow_wildcard=True), Atom("dev-libs/*", allow_wildcard=True)], True), + ("dev-libs/A-1:0", [Atom("dev-*/*", allow_wildcard=True), Atom("dev-*/*:0", allow_wildcard=True), + Atom("dev-libs/A"), Atom("<=dev-libs/A-2"), Atom("dev-libs/A:0"), + Atom("=dev-libs/A-1*"), Atom("~dev-libs/A-1"), Atom("=dev-libs/A-1")], + [Atom("=dev-libs/A-1"), Atom("~dev-libs/A-1"), Atom("=dev-libs/A-1*"), + Atom("dev-libs/A:0"), Atom("<=dev-libs/A-2"), Atom("dev-libs/A"), + Atom("dev-*/*:0", allow_wildcard=True), Atom("dev-*/*", allow_wildcard=True)], False) + ] for pkg, atom_list, result, all_permutations in tests: if all_permutations: diff --git a/pym/portage/tests/dep/test_dep_getcpv.py b/pym/portage/tests/dep/test_dep_getcpv.py index 8a0a8aa2f..79c1514a1 100644 --- a/pym/portage/tests/dep/test_dep_getcpv.py +++ b/pym/portage/tests/dep/test_dep_getcpv.py @@ -10,12 +10,14 @@ class DepGetCPV(TestCase): """ def testDepGetCPV(self): - - prefix_ops = ["<", ">", "=", "~", "<=", - ">=", "!=", "!<", "!>", "!~"] - bad_prefix_ops = [ ">~", "<~", "~>", "~<" ] - postfix_ops = [ ("=", "*"), ] + prefix_ops = [ + "<", ">", "=", "~", "<=", + ">=", "!=", "!<", "!>", "!~" + ] + + bad_prefix_ops = [">~", "<~", "~>", "~<"] + postfix_ops = [("=", "*"),] cpvs = ["sys-apps/portage-2.1", "sys-apps/portage-2.1", "sys-apps/portage-2.1"] @@ -26,10 +28,10 @@ class DepGetCPV(TestCase): mycpv = prefix + cpv if slot: mycpv += slot - self.assertEqual( dep_getcpv( mycpv ), cpv ) + self.assertEqual(dep_getcpv(mycpv), cpv) for prefix, postfix in postfix_ops: mycpv = prefix + cpv + postfix if slot: mycpv += slot - self.assertEqual( dep_getcpv( mycpv ), cpv ) + self.assertEqual(dep_getcpv(mycpv), cpv) diff --git a/pym/portage/tests/dep/test_dep_getrepo.py b/pym/portage/tests/dep/test_dep_getrepo.py index 78ead8cee..6c17d3cf7 100644 --- a/pym/portage/tests/dep/test_dep_getrepo.py +++ b/pym/portage/tests/dep/test_dep_getrepo.py @@ -11,9 +11,9 @@ class DepGetRepo(TestCase): def testDepGetRepo(self): repo_char = "::" - repos = ( "a", "repo-name", "repo_name", "repo123", None ) + repos = ("a", "repo-name", "repo_name", "repo123", None) cpvs = ["sys-apps/portage"] - versions = ["2.1.1","2.1-r1", None] + versions = ["2.1.1", "2.1-r1", None] uses = ["[use]", None] for cpv in cpvs: for version in versions: @@ -26,4 +26,4 @@ class DepGetRepo(TestCase): pkg = pkg + repo_char + repo if use: pkg = pkg + use - self.assertEqual( dep_getrepo( pkg ), repo ) + self.assertEqual(dep_getrepo(pkg), repo) diff --git a/pym/portage/tests/dep/test_dep_getslot.py b/pym/portage/tests/dep/test_dep_getslot.py index 206cecc8c..84828648b 100644 --- a/pym/portage/tests/dep/test_dep_getslot.py +++ b/pym/portage/tests/dep/test_dep_getslot.py @@ -12,9 +12,9 @@ class DepGetSlot(TestCase): def testDepGetSlot(self): slot_char = ":" - slots = ( "a", "1.2", "1", "IloveVapier", None ) + slots = ("a", "1.2", "1", "IloveVapier", None) cpvs = ["sys-apps/portage"] - versions = ["2.1.1","2.1-r1"] + versions = ["2.1.1", "2.1-r1"] for cpv in cpvs: for version in versions: for slot in slots: @@ -22,7 +22,7 @@ class DepGetSlot(TestCase): if version: mycpv = '=' + mycpv + '-' + version if slot is not None: - self.assertEqual( dep_getslot( - mycpv + slot_char + slot ), slot ) + self.assertEqual(dep_getslot( + mycpv + slot_char + slot), slot) else: - self.assertEqual( dep_getslot( mycpv ), slot ) + self.assertEqual(dep_getslot(mycpv), slot) diff --git a/pym/portage/tests/dep/test_dep_getusedeps.py b/pym/portage/tests/dep/test_dep_getusedeps.py index d2494f7b3..cd58eab35 100644 --- a/pym/portage/tests/dep/test_dep_getusedeps.py +++ b/pym/portage/tests/dep/test_dep_getusedeps.py @@ -24,12 +24,12 @@ class DepGetUseDeps(TestCase): cpv += ":" + slot if isinstance(use, tuple): cpv += "[%s]" % (",".join(use),) - self.assertEqual( dep_getusedeps( - cpv ), use ) + self.assertEqual(dep_getusedeps( + cpv), use) else: if len(use): - self.assertEqual( dep_getusedeps( - cpv + "[" + use + "]" ), (use,) ) + self.assertEqual(dep_getusedeps( + cpv + "[" + use + "]"), (use,)) else: - self.assertEqual( dep_getusedeps( - cpv + "[" + use + "]" ), () ) + self.assertEqual(dep_getusedeps( + cpv + "[" + use + "]"), ()) diff --git a/pym/portage/tests/dep/test_get_operator.py b/pym/portage/tests/dep/test_get_operator.py index 4f9848f5d..5076e2107 100644 --- a/pym/portage/tests/dep/test_get_operator.py +++ b/pym/portage/tests/dep/test_get_operator.py @@ -10,24 +10,28 @@ class GetOperator(TestCase): def testGetOperator(self): # get_operator does not validate operators - tests = [ ( "~", "~" ), ( "=", "=" ), ( ">", ">" ), - ( ">=", ">=" ), ( "<=", "<=" ), + tests = [ + ("~", "~"), + ("=", "="), + (">", ">"), + (">=", ">="), + ("<=", "<="), ] test_cpvs = ["sys-apps/portage-2.1"] - slots = [ None,"1","linux-2.5.6" ] + 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], - msg="get_operator(%s) != %s" % (test[0] + atom, test[1]) ) + result = get_operator(test[0] + atom) + self.assertEqual(result, test[1], + msg="get_operator(%s) != %s" % (test[0] + atom, test[1])) - result = get_operator( "sys-apps/portage" ) - self.assertEqual( result, None ) + result = get_operator("sys-apps/portage") + self.assertEqual(result, None) - result = get_operator( "=sys-apps/portage-2.1*" ) - self.assertEqual( result , "=*" ) + result = get_operator("=sys-apps/portage-2.1*") + self.assertEqual(result , "=*") diff --git a/pym/portage/tests/dep/test_isjustname.py b/pym/portage/tests/dep/test_isjustname.py index c16fb5493..9b95bcd0f 100644 --- a/pym/portage/tests/dep/test_isjustname.py +++ b/pym/portage/tests/dep/test_isjustname.py @@ -9,16 +9,16 @@ 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" ) + 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) ) + 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) ) + self.assertTrue(isjustname(cat + pkg + ver), + msg="isjustname(%s) is False!" % (cat + pkg + ver)) diff --git a/pym/portage/tests/dep/test_isvalidatom.py b/pym/portage/tests/dep/test_isvalidatom.py index 625bde5d4..6b0566da6 100644 --- a/pym/portage/tests/dep/test_isvalidatom.py +++ b/pym/portage/tests/dep/test_isvalidatom.py @@ -26,7 +26,7 @@ class IsValidAtom(TestCase): IsValidAtomTestCase("~sys-apps/portage-2.1", True), IsValidAtomTestCase("sys-apps/portage:foo", True), IsValidAtomTestCase("sys-apps/portage-2.1:foo", False), - IsValidAtomTestCase( "sys-apps/portage-2.1:", False), + IsValidAtomTestCase("sys-apps/portage-2.1:", False), IsValidAtomTestCase("sys-apps/portage-2.1:", False), IsValidAtomTestCase("sys-apps/portage-2.1:[foo]", False), IsValidAtomTestCase("sys-apps/portage", True), @@ -150,6 +150,6 @@ class IsValidAtom(TestCase): atom_type = "valid" else: atom_type = "invalid" - self.assertEqual( bool(isvalidatom(test_case.atom, allow_wildcard=test_case.allow_wildcard, \ + self.assertEqual(bool(isvalidatom(test_case.atom, allow_wildcard=test_case.allow_wildcard, allow_repo=test_case.allow_repo)), test_case.expected, - msg="isvalidatom(%s) != %s" % ( test_case.atom, test_case.expected ) ) + msg="isvalidatom(%s) != %s" % (test_case.atom, test_case.expected)) diff --git a/pym/portage/tests/dep/test_match_from_list.py b/pym/portage/tests/dep/test_match_from_list.py index 4a6ab3b48..b64862447 100644 --- a/pym/portage/tests/dep/test_match_from_list.py +++ b/pym/portage/tests/dep/test_match_from_list.py @@ -53,74 +53,74 @@ class Test_match_from_list(TestCase): def testMatch_from_list(self): tests = ( - ("=sys-apps/portage-45*", [], [] ), - ("=sys-apps/portage-45*", ["sys-apps/portage-045"], ["sys-apps/portage-045"] ), - ("!=sys-apps/portage-45*", ["sys-apps/portage-045"], ["sys-apps/portage-045"] ), - ("!!=sys-apps/portage-45*", ["sys-apps/portage-045"], ["sys-apps/portage-045"] ), - ("=sys-apps/portage-045", ["sys-apps/portage-045"], ["sys-apps/portage-045"] ), - ("=sys-apps/portage-045", ["sys-apps/portage-046"], [] ), - ("~sys-apps/portage-045", ["sys-apps/portage-045-r1"], ["sys-apps/portage-045-r1"] ), - ("~sys-apps/portage-045", ["sys-apps/portage-046-r1"], [] ), - ("<=sys-apps/portage-045", ["sys-apps/portage-045"], ["sys-apps/portage-045"] ), - ("<=sys-apps/portage-045", ["sys-apps/portage-046"], [] ), - ("=sys-apps/portage-045", ["sys-apps/portage-045"], ["sys-apps/portage-045"] ), - (">=sys-apps/portage-047", ["sys-apps/portage-046-r1"], [] ), - (">sys-apps/portage-044", ["sys-apps/portage-045"], ["sys-apps/portage-045"] ), - (">sys-apps/portage-047", ["sys-apps/portage-046-r1"], [] ), - ("sys-apps/portage:0", [Package("=sys-apps/portage-045:0")], ["sys-apps/portage-045"] ), - ("sys-apps/portage:0", [Package("=sys-apps/portage-045:1")], [] ), + ("=sys-apps/portage-45*", [], []), + ("=sys-apps/portage-45*", ["sys-apps/portage-045"], ["sys-apps/portage-045"]), + ("!=sys-apps/portage-45*", ["sys-apps/portage-045"], ["sys-apps/portage-045"]), + ("!!=sys-apps/portage-45*", ["sys-apps/portage-045"], ["sys-apps/portage-045"]), + ("=sys-apps/portage-045", ["sys-apps/portage-045"], ["sys-apps/portage-045"]), + ("=sys-apps/portage-045", ["sys-apps/portage-046"], []), + ("~sys-apps/portage-045", ["sys-apps/portage-045-r1"], ["sys-apps/portage-045-r1"]), + ("~sys-apps/portage-045", ["sys-apps/portage-046-r1"], []), + ("<=sys-apps/portage-045", ["sys-apps/portage-045"], ["sys-apps/portage-045"]), + ("<=sys-apps/portage-045", ["sys-apps/portage-046"], []), + ("=sys-apps/portage-045", ["sys-apps/portage-045"], ["sys-apps/portage-045"]), + (">=sys-apps/portage-047", ["sys-apps/portage-046-r1"], []), + (">sys-apps/portage-044", ["sys-apps/portage-045"], ["sys-apps/portage-045"]), + (">sys-apps/portage-047", ["sys-apps/portage-046-r1"], []), + ("sys-apps/portage:0", [Package("=sys-apps/portage-045:0")], ["sys-apps/portage-045"]), + ("sys-apps/portage:0", [Package("=sys-apps/portage-045:1")], []), ("=sys-fs/udev-1*", ["sys-fs/udev-123"], ["sys-fs/udev-123"]), - ("=sys-fs/udev-4*", ["sys-fs/udev-456"], ["sys-fs/udev-456"] ), - ("*/*", ["sys-fs/udev-456"], ["sys-fs/udev-456"] ), - ("*/*:0", ["sys-fs/udev-456:0"], ["sys-fs/udev-456:0"] ), - ("*/*:1", ["sys-fs/udev-456:0"], [] ), - ("sys-fs/*", ["sys-fs/udev-456"], ["sys-fs/udev-456"] ), - ("*/udev", ["sys-fs/udev-456"], ["sys-fs/udev-456"] ), - ("=sys-apps/portage-2*", ["sys-apps/portage-2.1"], ["sys-apps/portage-2.1"] ), - ("=sys-apps/portage-2.1*", ["sys-apps/portage-2.1.2"], ["sys-apps/portage-2.1.2"] ), - ("dev-libs/*", ["sys-apps/portage-2.1.2"], [] ), - ("*/tar", ["sys-apps/portage-2.1.2"], [] ), - ("*/*", ["dev-libs/A-1", "dev-libs/B-1"], ["dev-libs/A-1", "dev-libs/B-1"] ), - ("dev-libs/*", ["dev-libs/A-1", "sci-libs/B-1"], ["dev-libs/A-1"] ), + ("=sys-fs/udev-4*", ["sys-fs/udev-456"], ["sys-fs/udev-456"]), + ("*/*", ["sys-fs/udev-456"], ["sys-fs/udev-456"]), + ("*/*:0", ["sys-fs/udev-456:0"], ["sys-fs/udev-456:0"]), + ("*/*:1", ["sys-fs/udev-456:0"], []), + ("sys-fs/*", ["sys-fs/udev-456"], ["sys-fs/udev-456"]), + ("*/udev", ["sys-fs/udev-456"], ["sys-fs/udev-456"]), + ("=sys-apps/portage-2*", ["sys-apps/portage-2.1"], ["sys-apps/portage-2.1"]), + ("=sys-apps/portage-2.1*", ["sys-apps/portage-2.1.2"], ["sys-apps/portage-2.1.2"]), + ("dev-libs/*", ["sys-apps/portage-2.1.2"], []), + ("*/tar", ["sys-apps/portage-2.1.2"], []), + ("*/*", ["dev-libs/A-1", "dev-libs/B-1"], ["dev-libs/A-1", "dev-libs/B-1"]), + ("dev-libs/*", ["dev-libs/A-1", "sci-libs/B-1"], ["dev-libs/A-1"]), - ("dev-libs/A[foo]", [Package("=dev-libs/A-1[foo]"), Package("=dev-libs/A-2[-foo]")], ["dev-libs/A-1"] ), - ("dev-libs/A[-foo]", [Package("=dev-libs/A-1[foo]"), Package("=dev-libs/A-2[-foo]")], ["dev-libs/A-2"] ), - ("dev-libs/A[-foo]", [Package("=dev-libs/A-1[foo]"), Package("=dev-libs/A-2")], [] ), - ("dev-libs/A[foo,bar]", [Package("=dev-libs/A-1[foo]"), Package("=dev-libs/A-2[-foo]")], [] ), - ("dev-libs/A[foo,bar]", [Package("=dev-libs/A-1[foo]"), Package("=dev-libs/A-2[-foo,bar]")], [] ), - ("dev-libs/A[foo,bar]", [Package("=dev-libs/A-1[foo]"), Package("=dev-libs/A-2[foo,bar]")], ["dev-libs/A-2"] ), - ("dev-libs/A[foo,bar(+)]", [Package("=dev-libs/A-1[-foo]"), Package("=dev-libs/A-2[foo]")], ["dev-libs/A-2"] ), - ("dev-libs/A[foo,bar(-)]", [Package("=dev-libs/A-1[-foo]"), Package("=dev-libs/A-2[foo]")], [] ), - ("dev-libs/A[foo,-bar(-)]", [Package("=dev-libs/A-1[-foo,bar]"), Package("=dev-libs/A-2[foo]")], ["dev-libs/A-2"] ), + ("dev-libs/A[foo]", [Package("=dev-libs/A-1[foo]"), Package("=dev-libs/A-2[-foo]")], ["dev-libs/A-1"]), + ("dev-libs/A[-foo]", [Package("=dev-libs/A-1[foo]"), Package("=dev-libs/A-2[-foo]")], ["dev-libs/A-2"]), + ("dev-libs/A[-foo]", [Package("=dev-libs/A-1[foo]"), Package("=dev-libs/A-2")], []), + ("dev-libs/A[foo,bar]", [Package("=dev-libs/A-1[foo]"), Package("=dev-libs/A-2[-foo]")], []), + ("dev-libs/A[foo,bar]", [Package("=dev-libs/A-1[foo]"), Package("=dev-libs/A-2[-foo,bar]")], []), + ("dev-libs/A[foo,bar]", [Package("=dev-libs/A-1[foo]"), Package("=dev-libs/A-2[foo,bar]")], ["dev-libs/A-2"]), + ("dev-libs/A[foo,bar(+)]", [Package("=dev-libs/A-1[-foo]"), Package("=dev-libs/A-2[foo]")], ["dev-libs/A-2"]), + ("dev-libs/A[foo,bar(-)]", [Package("=dev-libs/A-1[-foo]"), Package("=dev-libs/A-2[foo]")], []), + ("dev-libs/A[foo,-bar(-)]", [Package("=dev-libs/A-1[-foo,bar]"), Package("=dev-libs/A-2[foo]")], ["dev-libs/A-2"]), - ("dev-libs/A::repo1", [Package("=dev-libs/A-1::repo1"), Package("=dev-libs/A-1::repo2")], ["dev-libs/A-1::repo1"] ), - ("dev-libs/A::repo2", [Package("=dev-libs/A-1::repo1"), Package("=dev-libs/A-1::repo2")], ["dev-libs/A-1::repo2"] ), - ("dev-libs/A::repo2[foo]", [Package("=dev-libs/A-1::repo1[foo]"), Package("=dev-libs/A-1::repo2[-foo]")], [] ), - ("dev-libs/A::repo2[foo]", [Package("=dev-libs/A-1::repo1[-foo]"), Package("=dev-libs/A-1::repo2[foo]")], ["dev-libs/A-1::repo2"] ), - ("dev-libs/A:1::repo2[foo]", [Package("=dev-libs/A-1:1::repo1"), Package("=dev-libs/A-1:2::repo2")], [] ), - ("dev-libs/A:1::repo2[foo]", [Package("=dev-libs/A-1:2::repo1"), Package("=dev-libs/A-1:1::repo2[foo]")], ["dev-libs/A-1::repo2"] ), + ("dev-libs/A::repo1", [Package("=dev-libs/A-1::repo1"), Package("=dev-libs/A-1::repo2")], ["dev-libs/A-1::repo1"]), + ("dev-libs/A::repo2", [Package("=dev-libs/A-1::repo1"), Package("=dev-libs/A-1::repo2")], ["dev-libs/A-1::repo2"]), + ("dev-libs/A::repo2[foo]", [Package("=dev-libs/A-1::repo1[foo]"), Package("=dev-libs/A-1::repo2[-foo]")], []), + ("dev-libs/A::repo2[foo]", [Package("=dev-libs/A-1::repo1[-foo]"), Package("=dev-libs/A-1::repo2[foo]")], ["dev-libs/A-1::repo2"]), + ("dev-libs/A:1::repo2[foo]", [Package("=dev-libs/A-1:1::repo1"), Package("=dev-libs/A-1:2::repo2")], []), + ("dev-libs/A:1::repo2[foo]", [Package("=dev-libs/A-1:2::repo1"), Package("=dev-libs/A-1:1::repo2[foo]")], ["dev-libs/A-1::repo2"]), - ("virtual/ffmpeg:0/53", [Package("=virtual/ffmpeg-0.10.3:0/53")], ["virtual/ffmpeg-0.10.3"] ), - ("virtual/ffmpeg:0/53=", [Package("=virtual/ffmpeg-0.10.3:0/53")], ["virtual/ffmpeg-0.10.3"] ), - ("virtual/ffmpeg:0/52", [Package("=virtual/ffmpeg-0.10.3:0/53")], [] ), - ("virtual/ffmpeg:=", [Package("=virtual/ffmpeg-0.10.3:0/53")], ["virtual/ffmpeg-0.10.3"] ), - ("virtual/ffmpeg:0=", [Package("=virtual/ffmpeg-0.10.3:0/53")], ["virtual/ffmpeg-0.10.3"] ), - ("virtual/ffmpeg:*", [Package("=virtual/ffmpeg-0.10.3:0/53")], ["virtual/ffmpeg-0.10.3"] ), - ("virtual/ffmpeg:0", [Package("=virtual/ffmpeg-0.10.3:0/53")], ["virtual/ffmpeg-0.10.3"] ), + ("virtual/ffmpeg:0/53", [Package("=virtual/ffmpeg-0.10.3:0/53")], ["virtual/ffmpeg-0.10.3"]), + ("virtual/ffmpeg:0/53=", [Package("=virtual/ffmpeg-0.10.3:0/53")], ["virtual/ffmpeg-0.10.3"]), + ("virtual/ffmpeg:0/52", [Package("=virtual/ffmpeg-0.10.3:0/53")], []), + ("virtual/ffmpeg:=", [Package("=virtual/ffmpeg-0.10.3:0/53")], ["virtual/ffmpeg-0.10.3"]), + ("virtual/ffmpeg:0=", [Package("=virtual/ffmpeg-0.10.3:0/53")], ["virtual/ffmpeg-0.10.3"]), + ("virtual/ffmpeg:*", [Package("=virtual/ffmpeg-0.10.3:0/53")], ["virtual/ffmpeg-0.10.3"]), + ("virtual/ffmpeg:0", [Package("=virtual/ffmpeg-0.10.3:0/53")], ["virtual/ffmpeg-0.10.3"]), - ("sys-libs/db:4.8/4.8", [Package("=sys-libs/db-4.8.30:4.8")], ["sys-libs/db-4.8.30"] ), - ("sys-libs/db:4.8/4.8=", [Package("=sys-libs/db-4.8.30:4.8")], ["sys-libs/db-4.8.30"] ), - ("sys-libs/db:4.8=", [Package("=sys-libs/db-4.8.30:4.8")], ["sys-libs/db-4.8.30"] ), - ("sys-libs/db:*", [Package("=sys-libs/db-4.8.30:4.8")], ["sys-libs/db-4.8.30"] ), - ("sys-libs/db:4.8/0", [Package("=sys-libs/db-4.8.30:4.8")], [] ), - ("sys-libs/db:4.8/0=", [Package("=sys-libs/db-4.8.30:4.8")], [] ), + ("sys-libs/db:4.8/4.8", [Package("=sys-libs/db-4.8.30:4.8")], ["sys-libs/db-4.8.30"]), + ("sys-libs/db:4.8/4.8=", [Package("=sys-libs/db-4.8.30:4.8")], ["sys-libs/db-4.8.30"]), + ("sys-libs/db:4.8=", [Package("=sys-libs/db-4.8.30:4.8")], ["sys-libs/db-4.8.30"]), + ("sys-libs/db:*", [Package("=sys-libs/db-4.8.30:4.8")], ["sys-libs/db-4.8.30"]), + ("sys-libs/db:4.8/0", [Package("=sys-libs/db-4.8.30:4.8")], []), + ("sys-libs/db:4.8/0=", [Package("=sys-libs/db-4.8.30:4.8")], []), ) for atom, cpv_list, expected_result in tests: result = [] - for pkg in match_from_list( atom, cpv_list ): + for pkg in match_from_list(atom, cpv_list): if isinstance(pkg, Package): if pkg.repo: result.append(pkg.cpv + _repo_separator + pkg.repo) @@ -128,4 +128,4 @@ class Test_match_from_list(TestCase): result.append(pkg.cpv) else: result.append(pkg) - self.assertEqual( result, expected_result ) + self.assertEqual(result, expected_result) diff --git a/pym/portage/tests/dep/test_paren_reduce.py b/pym/portage/tests/dep/test_paren_reduce.py index 1dfa64853..324465289 100644 --- a/pym/portage/tests/dep/test_paren_reduce.py +++ b/pym/portage/tests/dep/test_paren_reduce.py @@ -10,30 +10,30 @@ class TestParenReduce(TestCase): def testParenReduce(self): test_cases = ( - ( "A", ["A"]), - ( "( A )", ["A"]), - ( "|| ( A B )", [ "||", ["A", "B"] ]), - ( "|| ( A || ( B C ) )", [ "||", ["A", "||", ["B", "C"]]]), - ( "|| ( A || ( B C D ) )", [ "||", ["A", "||", ["B", "C", "D"]] ]), - ( "|| ( A || ( B || ( C D ) E ) )", [ "||", ["A", "||", ["B", "||", ["C", "D"], "E"]] ]), - ( "a? ( A )", ["a?", ["A"]]), - - ( "( || ( ( ( A ) B ) ) )", ["A", "B"]), - ( "( || ( || ( ( A ) B ) ) )", [ "||", ["A", "B"] ]), - ( "|| ( A )", ["A"]), - ( "( || ( || ( || ( A ) foo? ( B ) ) ) )", [ "||", ["A", "foo?", ["B"] ]]), - ( "( || ( || ( bar? ( A ) || ( foo? ( B ) ) ) ) )", [ "||", ["bar?", ["A"], "foo?", ["B"] ]]), - ( "A || ( ) foo? ( ) B", ["A", "B"]), + ("A", ["A"]), + ("( A )", ["A"]), + ("|| ( A B )", ["||", ["A", "B"]]), + ("|| ( A || ( B C ) )", ["||", ["A", "||", ["B", "C"]]]), + ("|| ( A || ( B C D ) )", ["||", ["A", "||", ["B", "C", "D"]]]), + ("|| ( A || ( B || ( C D ) E ) )", ["||", ["A", "||", ["B", "||", ["C", "D"], "E"]]]), + ("a? ( A )", ["a?", ["A"]]), - ( "|| ( A ) || ( B )", ["A", "B"]), - ( "foo? ( A ) foo? ( B )", ["foo?", ["A"], "foo?", ["B"]]), + ("( || ( ( ( A ) B ) ) )", ["A", "B"]), + ("( || ( || ( ( A ) B ) ) )", ["||", ["A", "B"]]), + ("|| ( A )", ["A"]), + ("( || ( || ( || ( A ) foo? ( B ) ) ) )", ["||", ["A", "foo?", ["B"]]]), + ("( || ( || ( bar? ( A ) || ( foo? ( B ) ) ) ) )", ["||", ["bar?", ["A"], "foo?", ["B"]]]), + ("A || ( ) foo? ( ) B", ["A", "B"]), - ( "|| ( ( A B ) C )", [ "||", [ ["A", "B"], "C"] ]), - ( "|| ( ( A B ) ( C ) )", [ "||", [ ["A", "B"], "C"] ]), + ("|| ( A ) || ( B )", ["A", "B"]), + ("foo? ( A ) foo? ( B )", ["foo?", ["A"], "foo?", ["B"]]), + + ("|| ( ( A B ) C )", ["||", [["A", "B"], "C"]]), + ("|| ( ( A B ) ( C ) )", ["||", [["A", "B"], "C"]]), # test USE dep defaults for bug #354003 - ( ">=dev-lang/php-5.2[pcre(+)]", [ ">=dev-lang/php-5.2[pcre(+)]" ]), + (">=dev-lang/php-5.2[pcre(+)]", [">=dev-lang/php-5.2[pcre(+)]"]), ) - + test_cases_xfail = ( "( A", "A )", @@ -47,13 +47,13 @@ class TestParenReduce(TestCase): "|| A B", "|| ( A B ) )", "|| || B C", - + "|| ( A B || )", - + "a? A", - - ( "( || ( || || ( A ) foo? ( B ) ) )"), - ( "( || ( || bar? ( A ) foo? ( B ) ) )"), + + "( || ( || || ( A ) foo? ( B ) ) )", + "( || ( || bar? ( A ) foo? ( B ) ) )", ) for dep_str, expected_result in test_cases: diff --git a/pym/portage/tests/dep/test_use_reduce.py b/pym/portage/tests/dep/test_use_reduce.py index 1618430c5..4f65567cf 100644 --- a/pym/portage/tests/dep/test_use_reduce.py +++ b/pym/portage/tests/dep/test_use_reduce.py @@ -6,10 +6,10 @@ from portage.exception import InvalidDependString from portage.dep import Atom, use_reduce class UseReduceTestCase(object): - def __init__(self, deparray, uselist=[], masklist=[], \ - matchall=0, excludeall=[], is_src_uri=False, \ - eapi="0", opconvert=False, flat=False, expected_result=None, \ - is_valid_flag=None, token_class=None): + def __init__(self, deparray, uselist=[], masklist=[], + matchall=0, excludeall=[], is_src_uri=False, + eapi='0', opconvert=False, flat=False, expected_result=None, + is_valid_flag=None, token_class=None): self.deparray = deparray self.uselist = uselist self.masklist = masklist @@ -25,8 +25,8 @@ class UseReduceTestCase(object): def run(self): try: - return use_reduce(self.deparray, self.uselist, self.masklist, \ - self.matchall, self.excludeall, self.is_src_uri, self.eapi, \ + return use_reduce(self.deparray, self.uselist, self.masklist, + self.matchall, self.excludeall, self.is_src_uri, self.eapi, self.opconvert, self.flat, self.is_valid_flag, self.token_class) except InvalidDependString as e: raise InvalidDependString("%s: %s" % (e, self.deparray)) @@ -47,508 +47,507 @@ class UseReduce(TestCase): test_cases = ( UseReduceTestCase( "a? ( A ) b? ( B ) !c? ( C ) !d? ( D )", - uselist = ["a", "b", "c", "d"], - expected_result = ["A", "B"] + uselist=["a", "b", "c", "d"], + expected_result=["A", "B"] ), UseReduceTestCase( "a? ( A ) b? ( B ) !c? ( C ) !d? ( D )", - uselist = ["a", "b", "c"], - expected_result = ["A", "B", "D"] + uselist=["a", "b", "c"], + expected_result=["A", "B", "D"] ), UseReduceTestCase( "a? ( A ) b? ( B ) !c? ( C ) !d? ( D )", - uselist = ["b", "c"], - expected_result = ["B", "D"] + uselist=["b", "c"], + expected_result=["B", "D"] ), UseReduceTestCase( "a? ( A ) b? ( B ) !c? ( C ) !d? ( D )", - matchall = True, - expected_result = ["A", "B", "C", "D"] + matchall=True, + expected_result=["A", "B", "C", "D"] ), UseReduceTestCase( "a? ( A ) b? ( B ) !c? ( C ) !d? ( D )", - masklist = ["a", "c"], - expected_result = ["C", "D"] + masklist=["a", "c"], + expected_result=["C", "D"] ), UseReduceTestCase( "a? ( A ) b? ( B ) !c? ( C ) !d? ( D )", - matchall = True, - masklist = ["a", "c"], - expected_result = ["B", "C", "D"] + matchall=True, + masklist=["a", "c"], + expected_result=["B", "C", "D"] ), UseReduceTestCase( "a? ( A ) b? ( B ) !c? ( C ) !d? ( D )", - uselist = ["a", "b"], - masklist = ["a", "c"], - expected_result = ["B", "C", "D"] + uselist=["a", "b"], + masklist=["a", "c"], + expected_result=["B", "C", "D"] ), UseReduceTestCase( "a? ( A ) b? ( B ) !c? ( C ) !d? ( D )", - excludeall = ["a", "c"], - expected_result = ["D"] + excludeall=["a", "c"], + expected_result=["D"] ), UseReduceTestCase( "a? ( A ) b? ( B ) !c? ( C ) !d? ( D )", - uselist = ["b"], - excludeall = ["a", "c"], - expected_result = ["B", "D"] + uselist=["b"], + excludeall=["a", "c"], + expected_result=["B", "D"] ), UseReduceTestCase( "a? ( A ) b? ( B ) !c? ( C ) !d? ( D )", - matchall = True, - excludeall = ["a", "c"], - expected_result = ["A", "B", "D"] + matchall=True, + excludeall=["a", "c"], + expected_result=["A", "B", "D"] ), UseReduceTestCase( "a? ( A ) b? ( B ) !c? ( C ) !d? ( D )", - matchall = True, - excludeall = ["a", "c"], - masklist = ["b"], - expected_result = ["A", "D"] + matchall=True, + excludeall=["a", "c"], + masklist=["b"], + expected_result=["A", "D"] ), - UseReduceTestCase( "a? ( b? ( AB ) )", - uselist = ["a", "b"], - expected_result = ["AB"] + uselist=["a", "b"], + expected_result=["AB"] ), UseReduceTestCase( "a? ( b? ( AB ) C )", - uselist = ["a"], - expected_result = ["C"] + uselist=["a"], + expected_result=["C"] ), UseReduceTestCase( "a? ( b? ( || ( AB CD ) ) )", - uselist = ["a", "b"], - expected_result = ["||", ["AB", "CD"]] + uselist=["a", "b"], + expected_result=["||", ["AB", "CD"]] ), UseReduceTestCase( "|| ( || ( a? ( A ) b? ( B ) ) )", - uselist = ["a", "b"], - expected_result = ["||", ["A", "B"]] + uselist=["a", "b"], + expected_result=["||", ["A", "B"]] ), UseReduceTestCase( "|| ( || ( a? ( A ) b? ( B ) ) )", - uselist = ["a"], - expected_result = ["A"] + uselist=["a"], + expected_result=["A"] ), UseReduceTestCase( "|| ( || ( a? ( A ) b? ( B ) ) )", - uselist = [], - expected_result = [] + uselist=[], + expected_result=[] ), UseReduceTestCase( "|| ( || ( a? ( || ( A c? ( C ) ) ) b? ( B ) ) )", - uselist = [], - expected_result = [] + uselist=[], + expected_result=[] ), UseReduceTestCase( "|| ( || ( a? ( || ( A c? ( C ) ) ) b? ( B ) ) )", - uselist = ["a"], - expected_result = ["A"] + uselist=["a"], + expected_result=["A"] ), UseReduceTestCase( "|| ( || ( a? ( || ( A c? ( C ) ) ) b? ( B ) ) )", - uselist = ["b"], - expected_result = ["B"] + uselist=["b"], + expected_result=["B"] ), UseReduceTestCase( "|| ( || ( a? ( || ( A c? ( C ) ) ) b? ( B ) ) )", - uselist = ["c"], - expected_result = [] + uselist=["c"], + expected_result=[] ), UseReduceTestCase( "|| ( || ( a? ( || ( A c? ( C ) ) ) b? ( B ) ) )", - uselist = ["a", "c"], - expected_result = ["||", [ "A", "C"]] + uselist=["a", "c"], + expected_result=["||", ["A", "C"]] ), - - #paren_reduce tests + + # paren_reduce tests UseReduceTestCase( "A", - expected_result = ["A"]), + expected_result=["A"]), UseReduceTestCase( "( A )", - expected_result = ["A"]), + expected_result=["A"]), UseReduceTestCase( "|| ( A B )", - expected_result = [ "||", ["A", "B"] ]), + expected_result=["||", ["A", "B"]]), UseReduceTestCase( "|| ( ( A B ) C )", - expected_result = [ "||", [ ["A", "B"], "C"] ]), + expected_result=["||", [["A", "B"], "C"]]), UseReduceTestCase( "|| ( ( A B ) ( C ) )", - expected_result = [ "||", [ ["A", "B"], "C"] ]), + expected_result=["||", [["A", "B"], "C"]]), UseReduceTestCase( "|| ( A || ( B C ) )", - expected_result = [ "||", ["A", "B", "C"]]), + expected_result=["||", ["A", "B", "C"]]), UseReduceTestCase( "|| ( A || ( B C D ) )", - expected_result = [ "||", ["A", "B", "C", "D"] ]), + expected_result=["||", ["A", "B", "C", "D"]]), UseReduceTestCase( "|| ( A || ( B || ( C D ) E ) )", - expected_result = [ "||", ["A", "B", "C", "D", "E"] ]), + expected_result=["||", ["A", "B", "C", "D", "E"]]), UseReduceTestCase( "( || ( ( ( A ) B ) ) )", - expected_result = ["A", "B"] ), + expected_result=["A", "B"]), UseReduceTestCase( "( || ( || ( ( A ) B ) ) )", - expected_result = [ "||", ["A", "B"] ]), + expected_result=["||", ["A", "B"]]), UseReduceTestCase( "( || ( || ( ( A ) B ) ) )", - expected_result = [ "||", ["A", "B"] ]), + expected_result=["||", ["A", "B"]]), UseReduceTestCase( "|| ( A )", - expected_result = ["A"]), + expected_result=["A"]), UseReduceTestCase( "( || ( || ( || ( A ) foo? ( B ) ) ) )", - expected_result = ["A"]), + expected_result=["A"]), UseReduceTestCase( "( || ( || ( || ( A ) foo? ( B ) ) ) )", - uselist = ["foo"], - expected_result = [ "||", ["A", "B"] ]), + uselist=["foo"], + expected_result=["||", ["A", "B"]]), UseReduceTestCase( "( || ( || ( bar? ( A ) || ( foo? ( B ) ) ) ) )", - expected_result = []), + expected_result=[]), UseReduceTestCase( "( || ( || ( bar? ( A ) || ( foo? ( B ) ) ) ) )", - uselist = ["foo", "bar"], - expected_result = [ "||", [ "A", "B" ] ]), + uselist=["foo", "bar"], + expected_result=["||", ["A", "B"]]), UseReduceTestCase( "A || ( bar? ( C ) ) foo? ( bar? ( C ) ) B", - expected_result = ["A", "B"]), + expected_result=["A", "B"]), UseReduceTestCase( "|| ( A ) || ( B )", - expected_result = ["A", "B"]), + expected_result=["A", "B"]), UseReduceTestCase( "foo? ( A ) foo? ( B )", - expected_result = []), + expected_result=[]), UseReduceTestCase( "foo? ( A ) foo? ( B )", - uselist = ["foo"], - expected_result = ["A", "B"]), + uselist=["foo"], + expected_result=["A", "B"]), UseReduceTestCase( "|| ( A B ) C", - expected_result = ['||', ['A', 'B'], 'C']), + expected_result=['||', ['A', 'B'], 'C']), UseReduceTestCase( "A || ( B C )", - expected_result = ['A', '||', ['B', 'C']]), + expected_result=['A', '||', ['B', 'C']]), - #SRC_URI stuff + # SRC_URI stuff UseReduceTestCase( "http://foo/bar -> blah.tbz2", - is_src_uri = True, - eapi = EAPI_WITH_SRC_URI_ARROWS, - expected_result = ["http://foo/bar", "->", "blah.tbz2"]), + is_src_uri=True, + eapi=EAPI_WITH_SRC_URI_ARROWS, + expected_result=["http://foo/bar", "->", "blah.tbz2"]), UseReduceTestCase( "foo? ( http://foo/bar -> blah.tbz2 )", - uselist = [], - is_src_uri = True, - eapi = EAPI_WITH_SRC_URI_ARROWS, - expected_result = []), + uselist=[], + is_src_uri=True, + eapi=EAPI_WITH_SRC_URI_ARROWS, + expected_result=[]), UseReduceTestCase( "foo? ( http://foo/bar -> blah.tbz2 )", - uselist = ["foo"], - is_src_uri = True, - eapi = EAPI_WITH_SRC_URI_ARROWS, - expected_result = ["http://foo/bar", "->", "blah.tbz2"]), + uselist=["foo"], + is_src_uri=True, + eapi=EAPI_WITH_SRC_URI_ARROWS, + expected_result=["http://foo/bar", "->", "blah.tbz2"]), UseReduceTestCase( "http://foo/bar -> bar.tbz2 foo? ( ftp://foo/a )", - uselist = [], - is_src_uri = True, - eapi = EAPI_WITH_SRC_URI_ARROWS, - expected_result = ["http://foo/bar", "->", "bar.tbz2"]), + uselist=[], + is_src_uri=True, + eapi=EAPI_WITH_SRC_URI_ARROWS, + expected_result=["http://foo/bar", "->", "bar.tbz2"]), UseReduceTestCase( "http://foo/bar -> bar.tbz2 foo? ( ftp://foo/a )", - uselist = ["foo"], - is_src_uri = True, - eapi = EAPI_WITH_SRC_URI_ARROWS, - expected_result = ["http://foo/bar", "->", "bar.tbz2", "ftp://foo/a"]), + uselist=["foo"], + is_src_uri=True, + eapi=EAPI_WITH_SRC_URI_ARROWS, + expected_result=["http://foo/bar", "->", "bar.tbz2", "ftp://foo/a"]), UseReduceTestCase( "http://foo.com/foo http://foo/bar -> blah.tbz2", - uselist = ["foo"], - is_src_uri = True, - eapi = EAPI_WITH_SRC_URI_ARROWS, - expected_result = ["http://foo.com/foo", "http://foo/bar", "->", "blah.tbz2"]), + uselist=["foo"], + is_src_uri=True, + eapi=EAPI_WITH_SRC_URI_ARROWS, + expected_result=["http://foo.com/foo", "http://foo/bar", "->", "blah.tbz2"]), - #opconvert tests + # opconvert tests UseReduceTestCase( "A", - opconvert = True, - expected_result = ["A"]), + opconvert=True, + expected_result=["A"]), UseReduceTestCase( "( A )", - opconvert = True, - expected_result = ["A"]), + opconvert=True, + expected_result=["A"]), UseReduceTestCase( "|| ( A B )", - opconvert = True, - expected_result = [['||', 'A', 'B']]), + opconvert=True, + expected_result=[['||', 'A', 'B']]), UseReduceTestCase( "|| ( ( A B ) C )", - opconvert = True, - expected_result = [['||', ['A', 'B'], 'C']]), + opconvert=True, + expected_result=[['||', ['A', 'B'], 'C']]), UseReduceTestCase( "|| ( A || ( B C ) )", - opconvert = True, - expected_result = [['||', 'A', 'B', 'C']]), + opconvert=True, + expected_result=[['||', 'A', 'B', 'C']]), UseReduceTestCase( "|| ( A || ( B C D ) )", - opconvert = True, - expected_result = [['||', 'A', 'B', 'C', 'D']]), + opconvert=True, + expected_result=[['||', 'A', 'B', 'C', 'D']]), UseReduceTestCase( "|| ( A || ( B || ( C D ) E ) )", - expected_result = [ "||", ["A", "B", "C", "D", "E"] ]), + expected_result=["||", ["A", "B", "C", "D", "E"]]), UseReduceTestCase( "( || ( ( ( A ) B ) ) )", - opconvert = True, - expected_result = [ "A", "B" ] ), + opconvert=True, + expected_result=['A', 'B']), UseReduceTestCase( "( || ( || ( ( A ) B ) ) )", - opconvert = True, - expected_result = [['||', 'A', 'B']]), + opconvert=True, + expected_result=[['||', 'A', 'B']]), UseReduceTestCase( "|| ( A B ) C", - opconvert = True, - expected_result = [['||', 'A', 'B'], 'C']), + opconvert=True, + expected_result=[['||', 'A', 'B'], 'C']), UseReduceTestCase( "A || ( B C )", - opconvert = True, - expected_result = ['A', ['||', 'B', 'C']]), + opconvert=True, + expected_result=['A', ['||', 'B', 'C']]), UseReduceTestCase( "A foo? ( || ( B || ( bar? ( || ( C D E ) ) !bar? ( F ) ) ) ) G", - uselist = ["foo", "bar"], - opconvert = True, - expected_result = ['A', ['||', 'B', 'C', 'D', 'E'], 'G']), + uselist=["foo", "bar"], + opconvert=True, + expected_result=['A', ['||', 'B', 'C', 'D', 'E'], 'G']), UseReduceTestCase( "A foo? ( || ( B || ( bar? ( || ( C D E ) ) !bar? ( F ) ) ) ) G", - uselist = ["foo", "bar"], - opconvert = False, - expected_result = ['A', '||', ['B', 'C', 'D', 'E'], 'G']), + uselist=["foo", "bar"], + opconvert=False, + expected_result=['A', '||', ['B', 'C', 'D', 'E'], 'G']), UseReduceTestCase( "|| ( A )", - opconvert = True, - expected_result = ["A"]), + opconvert=True, + expected_result=["A"]), UseReduceTestCase( "( || ( || ( || ( A ) foo? ( B ) ) ) )", - expected_result = ["A"]), + expected_result=["A"]), UseReduceTestCase( "( || ( || ( || ( A ) foo? ( B ) ) ) )", - uselist = ["foo"], - opconvert = True, - expected_result = [['||', 'A', 'B']]), + uselist=["foo"], + opconvert=True, + expected_result=[['||', 'A', 'B']]), UseReduceTestCase( "( || ( || ( bar? ( A ) || ( foo? ( B ) ) ) ) )", - opconvert = True, - expected_result = []), + opconvert=True, + expected_result=[]), UseReduceTestCase( "( || ( || ( bar? ( A ) || ( foo? ( B ) ) ) ) )", - uselist = ["foo", "bar"], - opconvert = True, - expected_result = [['||', 'A', 'B']]), + uselist=["foo", "bar"], + opconvert=True, + expected_result=[['||', 'A', 'B']]), UseReduceTestCase( "A || ( bar? ( C ) ) foo? ( bar? ( C ) ) B", - opconvert = True, - expected_result = ["A", "B"]), + opconvert=True, + expected_result=["A", "B"]), UseReduceTestCase( "|| ( A ) || ( B )", - opconvert = True, - expected_result = ["A", "B"]), + opconvert=True, + expected_result=["A", "B"]), UseReduceTestCase( "foo? ( A ) foo? ( B )", - opconvert = True, - expected_result = []), + opconvert=True, + expected_result=[]), UseReduceTestCase( "foo? ( A ) foo? ( B )", - uselist = ["foo"], - opconvert = True, - expected_result = ["A", "B"]), + uselist=["foo"], + opconvert=True, + expected_result=["A", "B"]), UseReduceTestCase( "|| ( foo? ( || ( A B ) ) )", - uselist = ["foo"], - opconvert = True, - expected_result = [['||', 'A', 'B']]), + uselist=["foo"], + opconvert=True, + expected_result=[['||', 'A', 'B']]), UseReduceTestCase( "|| ( ( A B ) foo? ( || ( C D ) ) )", - uselist = ["foo"], - opconvert = True, - expected_result = [['||', ['A', 'B'], 'C', 'D']]), + uselist=["foo"], + opconvert=True, + expected_result=[['||', ['A', 'B'], 'C', 'D']]), UseReduceTestCase( "|| ( ( A B ) foo? ( || ( C D ) ) )", - uselist = ["foo"], - opconvert = False, - expected_result = ['||', [['A', 'B'], 'C', 'D']]), + uselist=["foo"], + opconvert=False, + expected_result=['||', [['A', 'B'], 'C', 'D']]), UseReduceTestCase( "|| ( ( A B ) || ( C D ) )", - expected_result = ['||', [['A', 'B'], 'C', 'D']]), + expected_result=['||', [['A', 'B'], 'C', 'D']]), UseReduceTestCase( "|| ( ( A B ) || ( C D || ( E ( F G ) || ( H ) ) ) )", - expected_result = ['||', [['A', 'B'], 'C', 'D', 'E', ['F', 'G'], 'H']]), + expected_result=['||', [['A', 'B'], 'C', 'D', 'E', ['F', 'G'], 'H']]), UseReduceTestCase( "|| ( ( A B ) || ( C D || ( E ( F G ) || ( H ) ) ) )", - opconvert = True, - expected_result = [['||', ['A', 'B'], 'C', 'D', 'E', ['F', 'G'], 'H']]), + opconvert=True, + expected_result=[['||', ['A', 'B'], 'C', 'D', 'E', ['F', 'G'], 'H']]), UseReduceTestCase( "|| ( foo? ( A B ) )", - uselist = ["foo"], - expected_result = ['A', 'B']), + uselist=["foo"], + expected_result=['A', 'B']), UseReduceTestCase( "|| ( || ( foo? ( A B ) ) )", - uselist = ["foo"], - expected_result = ['A', 'B']), + uselist=["foo"], + expected_result=['A', 'B']), UseReduceTestCase( "|| ( || ( || ( a? ( b? ( c? ( || ( || ( || ( d? ( e? ( f? ( A B ) ) ) ) ) ) ) ) ) ) ) )", - uselist = ["a", "b", "c", "d", "e", "f"], - expected_result = ['A', 'B']), + uselist=["a", "b", "c", "d", "e", "f"], + expected_result=['A', 'B']), UseReduceTestCase( "|| ( || ( ( || ( a? ( ( b? ( c? ( || ( || ( || ( ( d? ( e? ( f? ( A B ) ) ) ) ) ) ) ) ) ) ) ) ) ) )", - uselist = ["a", "b", "c", "d", "e", "f"], - expected_result = ['A', 'B']), + uselist=["a", "b", "c", "d", "e", "f"], + expected_result=['A', 'B']), UseReduceTestCase( "|| ( ( A ( || ( B ) ) ) )", - expected_result = ['A', 'B']), + expected_result=['A', 'B']), UseReduceTestCase( "|| ( ( A B ) || ( foo? ( bar? ( ( C D || ( baz? ( E ) ( F G ) || ( H ) ) ) ) ) ) )", - uselist = ["foo", "bar", "baz"], - expected_result = ['||', [['A', 'B'], ['C', 'D', '||', ['E', ['F', 'G'], 'H']]]]), + uselist=["foo", "bar", "baz"], + expected_result=['||', [['A', 'B'], ['C', 'D', '||', ['E', ['F', 'G'], 'H']]]]), UseReduceTestCase( "|| ( ( A B ) || ( foo? ( bar? ( ( C D || ( baz? ( E ) ( F G ) || ( H ) ) ) ) ) ) )", - uselist = ["foo", "bar", "baz"], - opconvert = True, - expected_result = [['||', ['A', 'B'], ['C', 'D', ['||', 'E', ['F', 'G'], 'H']]]]), + uselist=["foo", "bar", "baz"], + opconvert=True, + expected_result=[['||', ['A', 'B'], ['C', 'D', ['||', 'E', ['F', 'G'], 'H']]]]), UseReduceTestCase( "|| ( foo? ( A B ) )", - uselist = ["foo"], + uselist=["foo"], opconvert=True, - expected_result = ['A', 'B']), + expected_result=['A', 'B']), UseReduceTestCase( "|| ( || ( foo? ( A B ) ) )", - uselist = ["foo"], + uselist=["foo"], opconvert=True, - expected_result = ['A', 'B']), + expected_result=['A', 'B']), UseReduceTestCase( "|| ( || ( || ( a? ( b? ( c? ( || ( || ( || ( d? ( e? ( f? ( A B ) ) ) ) ) ) ) ) ) ) ) )", - uselist = ["a", "b", "c", "d", "e", "f"], + uselist=["a", "b", "c", "d", "e", "f"], opconvert=True, - expected_result = ['A', 'B']), + expected_result=['A', 'B']), - #flat test + # flat test UseReduceTestCase( "A", - flat = True, - expected_result = ["A"]), + flat=True, + expected_result=["A"]), UseReduceTestCase( "( A )", - flat = True, - expected_result = ["A"]), + flat=True, + expected_result=["A"]), UseReduceTestCase( "|| ( A B )", - flat = True, - expected_result = [ "||", "A", "B" ] ), + flat=True, + expected_result=["||", "A", "B"]), UseReduceTestCase( "|| ( A || ( B C ) )", - flat = True, - expected_result = [ "||", "A", "||", "B", "C" ]), + flat=True, + expected_result=["||", "A", "||", "B", "C"]), UseReduceTestCase( "|| ( A || ( B C D ) )", - flat = True, - expected_result = [ "||", "A", "||", "B", "C", "D" ]), + flat=True, + expected_result=["||", "A", "||", "B", "C", "D"]), UseReduceTestCase( "|| ( A || ( B || ( C D ) E ) )", - flat = True, - expected_result = [ "||", "A", "||", "B", "||", "C", "D", "E" ]), + flat=True, + expected_result=["||", "A", "||", "B", "||", "C", "D", "E"]), UseReduceTestCase( "( || ( ( ( A ) B ) ) )", - flat = True, - expected_result = [ "||", "A", "B"] ), + flat=True, + expected_result=["||", "A", "B"]), UseReduceTestCase( "( || ( || ( ( A ) B ) ) )", - flat = True, - expected_result = [ "||", "||", "A", "B" ]), + flat=True, + expected_result=["||", "||", "A", "B"]), UseReduceTestCase( "( || ( || ( ( A ) B ) ) )", - flat = True, - expected_result = [ "||", "||", "A", "B" ]), + flat=True, + expected_result=["||", "||", "A", "B"]), UseReduceTestCase( "|| ( A )", - flat = True, - expected_result = ["||", "A"]), + flat=True, + expected_result=["||", "A"]), UseReduceTestCase( "( || ( || ( || ( A ) foo? ( B ) ) ) )", - expected_result = ["A"]), + expected_result=["A"]), UseReduceTestCase( "( || ( || ( || ( A ) foo? ( B ) ) ) )", - uselist = ["foo"], - flat = True, - expected_result = [ "||", "||","||", "A", "B" ]), + uselist=["foo"], + flat=True, + expected_result=["||", "||", "||", "A", "B"]), UseReduceTestCase( "( || ( || ( bar? ( A ) || ( foo? ( B ) ) ) ) )", - flat = True, - expected_result = ["||", "||","||"]), + flat=True, + expected_result=["||", "||", "||"]), UseReduceTestCase( "( || ( || ( bar? ( A ) || ( foo? ( B ) ) ) ) )", - uselist = ["foo", "bar"], - flat = True, - expected_result = [ "||", "||", "A", "||", "B" ]), + uselist=["foo", "bar"], + flat=True, + expected_result=["||", "||", "A", "||", "B"]), UseReduceTestCase( "A || ( bar? ( C ) ) foo? ( bar? ( C ) ) B", - flat = True, - expected_result = ["A", "||", "B"]), + flat=True, + expected_result=["A", "||", "B"]), UseReduceTestCase( "|| ( A ) || ( B )", - flat = True, - expected_result = ["||", "A", "||", "B"]), + flat=True, + expected_result=["||", "A", "||", "B"]), UseReduceTestCase( "foo? ( A ) foo? ( B )", - flat = True, - expected_result = []), + flat=True, + expected_result=[]), UseReduceTestCase( "foo? ( A ) foo? ( B )", - uselist = ["foo"], - flat = True, - expected_result = ["A", "B"]), + uselist=["foo"], + flat=True, + expected_result=["A", "B"]), - #use flag validation + # use flag validation UseReduceTestCase( "foo? ( A )", - uselist = ["foo"], - is_valid_flag = self.always_true, - expected_result = ["A"]), + uselist=["foo"], + is_valid_flag=self.always_true, + expected_result=["A"]), UseReduceTestCase( "foo? ( A )", - is_valid_flag = self.always_true, - expected_result = []), + is_valid_flag=self.always_true, + expected_result=[]), - #token_class + # token_class UseReduceTestCase( "foo? ( dev-libs/A )", - uselist = ["foo"], + uselist=["foo"], token_class=Atom, - expected_result = ["dev-libs/A"]), + expected_result=["dev-libs/A"]), UseReduceTestCase( "foo? ( dev-libs/A )", token_class=Atom, - expected_result = []), + expected_result=[]), ) - + test_cases_xfail = ( UseReduceTestCase("? ( A )"), UseReduceTestCase("!? ( A )"), @@ -571,44 +570,44 @@ class UseReduce(TestCase): UseReduceTestCase("|| ( )"), UseReduceTestCase("foo? ( )"), - #SRC_URI stuff - UseReduceTestCase("http://foo/bar -> blah.tbz2", is_src_uri = True, eapi = EAPI_WITHOUT_SRC_URI_ARROWS), - UseReduceTestCase("|| ( http://foo/bar -> blah.tbz2 )", is_src_uri = True, eapi = EAPI_WITH_SRC_URI_ARROWS), - UseReduceTestCase("http://foo/bar -> foo? ( ftp://foo/a )", is_src_uri = True, eapi = EAPI_WITH_SRC_URI_ARROWS), - UseReduceTestCase("http://foo/bar blah.tbz2 ->", is_src_uri = True, eapi = EAPI_WITH_SRC_URI_ARROWS), - UseReduceTestCase("-> http://foo/bar blah.tbz2 )", is_src_uri = True, eapi = EAPI_WITH_SRC_URI_ARROWS), - UseReduceTestCase("http://foo/bar ->", is_src_uri = True, eapi = EAPI_WITH_SRC_URI_ARROWS), - UseReduceTestCase("http://foo/bar -> foo? ( http://foo.com/foo )", is_src_uri = True, eapi = EAPI_WITH_SRC_URI_ARROWS), - UseReduceTestCase("foo? ( http://foo/bar -> ) blah.tbz2", is_src_uri = True, eapi = EAPI_WITH_SRC_URI_ARROWS), - UseReduceTestCase("http://foo/bar -> foo/blah.tbz2", is_src_uri = True, eapi = EAPI_WITH_SRC_URI_ARROWS), - UseReduceTestCase("http://foo/bar -> -> bar.tbz2 foo? ( ftp://foo/a )", is_src_uri = True, eapi = EAPI_WITH_SRC_URI_ARROWS), - - UseReduceTestCase("http://foo/bar -> bar.tbz2 foo? ( ftp://foo/a )", is_src_uri = False, eapi = EAPI_WITH_SRC_URI_ARROWS), + # SRC_URI stuff + UseReduceTestCase("http://foo/bar -> blah.tbz2", is_src_uri=True, eapi=EAPI_WITHOUT_SRC_URI_ARROWS), + UseReduceTestCase("|| ( http://foo/bar -> blah.tbz2 )", is_src_uri=True, eapi=EAPI_WITH_SRC_URI_ARROWS), + UseReduceTestCase("http://foo/bar -> foo? ( ftp://foo/a )", is_src_uri=True, eapi=EAPI_WITH_SRC_URI_ARROWS), + UseReduceTestCase("http://foo/bar blah.tbz2 ->", is_src_uri=True, eapi=EAPI_WITH_SRC_URI_ARROWS), + UseReduceTestCase("-> http://foo/bar blah.tbz2 )", is_src_uri=True, eapi=EAPI_WITH_SRC_URI_ARROWS), + UseReduceTestCase("http://foo/bar ->", is_src_uri=True, eapi=EAPI_WITH_SRC_URI_ARROWS), + UseReduceTestCase("http://foo/bar -> foo? ( http://foo.com/foo )", is_src_uri=True, eapi=EAPI_WITH_SRC_URI_ARROWS), + UseReduceTestCase("foo? ( http://foo/bar -> ) blah.tbz2", is_src_uri=True, eapi=EAPI_WITH_SRC_URI_ARROWS), + UseReduceTestCase("http://foo/bar -> foo/blah.tbz2", is_src_uri=True, eapi=EAPI_WITH_SRC_URI_ARROWS), + UseReduceTestCase("http://foo/bar -> -> bar.tbz2 foo? ( ftp://foo/a )", is_src_uri=True, eapi=EAPI_WITH_SRC_URI_ARROWS), + + UseReduceTestCase("http://foo/bar -> bar.tbz2 foo? ( ftp://foo/a )", is_src_uri=False, eapi=EAPI_WITH_SRC_URI_ARROWS), UseReduceTestCase( "A", - opconvert = True, - flat = True), + opconvert=True, + flat=True), - #use flag validation + # use flag validation UseReduceTestCase("1.0? ( A )"), UseReduceTestCase("!1.0? ( A )"), UseReduceTestCase("!? ( A )"), UseReduceTestCase("!?? ( A )"), UseReduceTestCase( "foo? ( A )", - is_valid_flag = self.always_false, + is_valid_flag=self.always_false, ), UseReduceTestCase( "foo? ( A )", - uselist = ["foo"], - is_valid_flag = self.always_false, + uselist=["foo"], + is_valid_flag=self.always_false, ), - #token_class + # token_class UseReduceTestCase( "foo? ( A )", - uselist = ["foo"], + uselist=["foo"], token_class=Atom), UseReduceTestCase( "A(B", diff --git a/pym/portage/tests/ebuild/test_config.py b/pym/portage/tests/ebuild/test_config.py index 63cb99d41..38e8b6edb 100644 --- a/pym/portage/tests/ebuild/test_config.py +++ b/pym/portage/tests/ebuild/test_config.py @@ -46,7 +46,7 @@ class ConfigTestCase(TestCase): settings.features.add('noclean') self.assertEqual('noclean' in settings['FEATURES'].split(), True) settings.regenerate() - self.assertEqual('noclean' in settings['FEATURES'].split(),True) + self.assertEqual('noclean' in settings['FEATURES'].split(), True) settings.features.discard('noclean') self.assertEqual('noclean' in settings['FEATURES'].split(), False) @@ -56,7 +56,7 @@ class ConfigTestCase(TestCase): settings.features.add('noclean') self.assertEqual('noclean' in settings['FEATURES'].split(), True) settings.regenerate() - self.assertEqual('noclean' in settings['FEATURES'].split(),True) + self.assertEqual('noclean' in settings['FEATURES'].split(), True) # before: ['noclean', '-noclean', 'noclean'] settings.features._prune_overrides() diff --git a/pym/portage/tests/env/config/test_PackageKeywordsFile.py b/pym/portage/tests/env/config/test_PackageKeywordsFile.py index f1e9e98f0..609c0fda2 100644 --- a/pym/portage/tests/env/config/test_PackageKeywordsFile.py +++ b/pym/portage/tests/env/config/test_PackageKeywordsFile.py @@ -11,7 +11,7 @@ class PackageKeywordsFileTestCase(TestCase): cpv = ['sys-apps/portage'] keywords = ['~x86', 'amd64', '-mips'] - + def testPackageKeywordsFile(self): """ A simple test to ensure the load works properly @@ -23,17 +23,17 @@ class PackageKeywordsFileTestCase(TestCase): f.load() i = 0 for cpv, keyword in f.items(): - self.assertEqual( cpv, self.cpv[i] ) + self.assertEqual(cpv, self.cpv[i]) [k for k in keyword if self.assertTrue(k in self.keywords)] i = i + 1 finally: self.NukeFile() - + def BuildFile(self): fd, self.fname = mkstemp() f = os.fdopen(fd, 'w') for c in self.cpv: - f.write("%s %s\n" % (c,' '.join(self.keywords))) + f.write("%s %s\n" % (c, ' '.join(self.keywords))) f.close() def NukeFile(self): diff --git a/pym/portage/tests/env/config/test_PackageUseFile.py b/pym/portage/tests/env/config/test_PackageUseFile.py index 7a3806792..b1a6ccbde 100644 --- a/pym/portage/tests/env/config/test_PackageUseFile.py +++ b/pym/portage/tests/env/config/test_PackageUseFile.py @@ -12,7 +12,7 @@ class PackageUseFileTestCase(TestCase): cpv = 'sys-apps/portage' useflags = ['cdrom', 'far', 'boo', 'flag', 'blat'] - + def testPackageUseFile(self): """ A simple test to ensure the load works properly @@ -22,7 +22,7 @@ class PackageUseFileTestCase(TestCase): f = PackageUseFile(self.fname) f.load() for cpv, use in f.items(): - self.assertEqual( cpv, self.cpv ) + self.assertEqual(cpv, self.cpv) [flag for flag in use if self.assertTrue(flag in self.useflags)] finally: self.NukeFile() @@ -32,6 +32,6 @@ class PackageUseFileTestCase(TestCase): f = os.fdopen(fd, 'w') f.write("%s %s" % (self.cpv, ' '.join(self.useflags))) f.close() - + def NukeFile(self): os.unlink(self.fname) diff --git a/pym/portage/tests/env/config/test_PortageModulesFile.py b/pym/portage/tests/env/config/test_PortageModulesFile.py index 2cd1a8ab1..05584a5f8 100644 --- a/pym/portage/tests/env/config/test_PortageModulesFile.py +++ b/pym/portage/tests/env/config/test_PortageModulesFile.py @@ -8,14 +8,13 @@ from tempfile import mkstemp class PortageModulesFileTestCase(TestCase): - keys = ['foo.bar','baz','bob','extra_key'] - invalid_keys = ['',""] - modules = ['spanky','zmedico','antarus','ricer','5','6'] + keys = ['foo.bar', 'baz', 'bob', 'extra_key'] + invalid_keys = ['', ""] + modules = ['spanky', 'zmedico', 'antarus', 'ricer', '5', '6'] def setUp(self): self.items = {} - for k, v in zip(self.keys + self.invalid_keys, - self.modules): + for k, v in zip(self.keys + self.invalid_keys, self.modules): self.items[k] = v def testPortageModulesFile(self): @@ -32,7 +31,7 @@ class PortageModulesFileTestCase(TestCase): fd, self.fname = mkstemp() f = os.fdopen(fd, 'w') for k, v in self.items.items(): - f.write('%s=%s\n' % (k,v)) + f.write('%s=%s\n' % (k, v)) f.close() def NukeFile(self): diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py index cd0944210..dd5e17cfc 100644 --- a/pym/portage/tests/resolver/ResolverPlayground.py +++ b/pym/portage/tests/resolver/ResolverPlayground.py @@ -59,7 +59,7 @@ class ResolverPlayground(object): user_config={}, sets={}, world=[], world_sets=[], distfiles={}, targetroot=False, debug=False): """ - ebuilds: cpv -> metadata mapping simulating available ebuilds. + ebuilds: cpv -> metadata mapping simulating available ebuilds. installed: cpv -> metadata mapping simulating installed packages. If a metadata key is missing, it gets a default value. profile: settings defined by the profile. @@ -95,7 +95,7 @@ class ResolverPlayground(object): self.settings, self.trees = self._load_config() self._create_ebuild_manifests(ebuilds) - + portage.util.noiselimit = 0 def _get_repo_dir(self, repo): @@ -273,17 +273,17 @@ class ResolverPlayground(object): for cat in categories: f.write(cat + "\n") f.close() - + #Create $REPO/profiles/license_groups license_file = os.path.join(profile_dir, "license_groups") f = open(license_file, "w") f.write("EULA TEST\n") f.close() - repo_config = repo_configs.get(repo) + repo_config = repo_configs.get(repo) if repo_config: for config_file, lines in repo_config.items(): - if config_file not in self.config_files and not any(fnmatch.fnmatch(config_file, os.path.join(x, "*")) for x in self.config_files): + if config_file not in self.config_files and not any(fnmatch.fnmatch(config_file, os.path.join(x, "*")) for x in self.config_files): raise ValueError("Unknown config file: '%s'" % config_file) if config_file in ("layout.conf",): @@ -364,7 +364,7 @@ class ResolverPlayground(object): # Write empty entries for each repository, in order to exercise # RepoConfigLoader's repos.conf processing. - repos_conf_file = os.path.join(user_config_dir, "repos.conf") + repos_conf_file = os.path.join(user_config_dir, "repos.conf") f = open(repos_conf_file, "w") for repo in sorted(self.repo_dirs.keys()): f.write("[%s]\n" % repo) @@ -434,7 +434,7 @@ class ResolverPlayground(object): #Create /usr/share/portage/config/sets/portage.conf default_sets_conf_dir = os.path.join(self.eroot, "usr/share/portage/config/sets") - + try: os.makedirs(default_sets_conf_dir) except os.error: @@ -520,7 +520,7 @@ class ResolverPlayground(object): rval, cleanlist, ordered, req_pkg_count = \ calc_depclean(self.settings, self.trees, None, options, action, InternalPackageSet(initial_atoms=atoms, allow_wildcard=True), None) - result = ResolverPlaygroundDepcleanResult( \ + result = ResolverPlaygroundDepcleanResult( atoms, rval, cleanlist, ordered, req_pkg_count) else: params = create_depgraph_params(options, action) @@ -764,7 +764,7 @@ class ResolverPlaygroundResult(object): if self.depgraph._dynamic_config._circular_dependency_handler is not None: handler = self.depgraph._dynamic_config._circular_dependency_handler sol = handler.solutions - self.circular_dependency_solutions = dict( zip([x.cpv for x in sol.keys()], sol.values()) ) + self.circular_dependency_solutions = dict(zip([x.cpv for x in sol.keys()], sol.values())) class ResolverPlaygroundDepcleanResult(object): diff --git a/pym/portage/tests/resolver/test_autounmask.py b/pym/portage/tests/resolver/test_autounmask.py index 6acac9984..75fb36843 100644 --- a/pym/portage/tests/resolver/test_autounmask.py +++ b/pym/portage/tests/resolver/test_autounmask.py @@ -10,9 +10,9 @@ class AutounmaskTestCase(TestCase): ebuilds = { #ebuilds to test use changes - "dev-libs/A-1": { "SLOT": 1, "DEPEND": "dev-libs/B[foo]", "EAPI": 2}, - "dev-libs/A-2": { "SLOT": 2, "DEPEND": "dev-libs/B[bar]", "EAPI": 2}, - "dev-libs/B-1": { "DEPEND": "foo? ( dev-libs/C ) bar? ( dev-libs/D )", "IUSE": "foo bar"}, + "dev-libs/A-1": { "SLOT": 1, "DEPEND": "dev-libs/B[foo]", "EAPI": 2}, + "dev-libs/A-2": { "SLOT": 2, "DEPEND": "dev-libs/B[bar]", "EAPI": 2}, + "dev-libs/B-1": { "DEPEND": "foo? ( dev-libs/C ) bar? ( dev-libs/D )", "IUSE": "foo bar"}, "dev-libs/C-1": {}, "dev-libs/D-1": {}, @@ -56,10 +56,10 @@ class AutounmaskTestCase(TestCase): "dev-util/R-1": { "IUSE": "bar" }, #ebuilds to test interaction with REQUIRED_USE - "app-portage/A-1": { "DEPEND": "app-portage/B[foo]", "EAPI": 2 }, - "app-portage/A-2": { "DEPEND": "app-portage/B[foo=]", "IUSE": "+foo", "REQUIRED_USE": "foo", "EAPI": "4" }, + "app-portage/A-1": { "DEPEND": "app-portage/B[foo]", "EAPI": 2 }, + "app-portage/A-2": { "DEPEND": "app-portage/B[foo=]", "IUSE": "+foo", "REQUIRED_USE": "foo", "EAPI": "4" }, - "app-portage/B-1": { "IUSE": "foo +bar", "REQUIRED_USE": "^^ ( foo bar )", "EAPI": "4" }, + "app-portage/B-1": { "IUSE": "foo +bar", "REQUIRED_USE": "^^ ( foo bar )", "EAPI": "4" }, "app-portage/C-1": { "IUSE": "+foo +bar", "REQUIRED_USE": "^^ ( foo bar )", "EAPI": "4" }, } @@ -69,183 +69,183 @@ class AutounmaskTestCase(TestCase): ResolverPlaygroundTestCase( ["dev-libs/A:1"], - options = {"--autounmask": "n"}, - success = False), + options={"--autounmask": "n"}, + success=False), ResolverPlaygroundTestCase( ["dev-libs/A:1"], - options = {"--autounmask": True}, - success = False, - mergelist = ["dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1"], - use_changes = { "dev-libs/B-1": {"foo": True} } ), + options={"--autounmask": True}, + success=False, + mergelist=["dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1"], + use_changes={ "dev-libs/B-1": {"foo": True} }), #Make sure we restart if needed. ResolverPlaygroundTestCase( ["dev-libs/A:1", "dev-libs/B"], - options = {"--autounmask": True}, - all_permutations = True, - success = False, - mergelist = ["dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1"], - use_changes = { "dev-libs/B-1": {"foo": True} } ), + options={"--autounmask": True}, + all_permutations=True, + success=False, + mergelist=["dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1"], + use_changes={ "dev-libs/B-1": {"foo": True} }), ResolverPlaygroundTestCase( ["dev-libs/A:1", "dev-libs/A:2", "dev-libs/B"], - options = {"--autounmask": True}, - all_permutations = True, - success = False, - mergelist = ["dev-libs/D-1", "dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1", "dev-libs/A-2"], - ignore_mergelist_order = True, - use_changes = { "dev-libs/B-1": {"foo": True, "bar": True} } ), + options={"--autounmask": True}, + all_permutations=True, + success=False, + mergelist=["dev-libs/D-1", "dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1", "dev-libs/A-2"], + ignore_mergelist_order=True, + use_changes={ "dev-libs/B-1": {"foo": True, "bar": True} }), #Test keywording. #The simple case. ResolverPlaygroundTestCase( ["app-misc/Z"], - options = {"--autounmask": "n"}, - success = False), + options={"--autounmask": "n"}, + success=False), ResolverPlaygroundTestCase( ["app-misc/Z"], - options = {"--autounmask": True}, - success = False, - mergelist = ["app-misc/Y-1", "app-misc/Z-1"], - unstable_keywords = ["app-misc/Y-1", "app-misc/Z-1"]), + options={"--autounmask": True}, + success=False, + mergelist=["app-misc/Y-1", "app-misc/Z-1"], + unstable_keywords=["app-misc/Y-1", "app-misc/Z-1"]), #Make sure that the backtracking for slot conflicts handles our mess. ResolverPlaygroundTestCase( ["=app-misc/V-1", "app-misc/W"], - options = {"--autounmask": True}, - all_permutations = True, - success = False, - mergelist = ["app-misc/W-2", "app-misc/V-1"], - unstable_keywords = ["app-misc/W-2", "app-misc/V-1"]), + options={"--autounmask": True}, + all_permutations=True, + success=False, + mergelist=["app-misc/W-2", "app-misc/V-1"], + unstable_keywords=["app-misc/W-2", "app-misc/V-1"]), #Mixed testing #Make sure we don't change use for something in a || dep if there is another choice #that needs no change. - + ResolverPlaygroundTestCase( ["=sci-libs/K-1"], - options = {"--autounmask": True}, - success = True, - mergelist = ["sci-libs/P-1", "sci-libs/K-1"]), + options={"--autounmask": True}, + success=True, + mergelist=["sci-libs/P-1", "sci-libs/K-1"]), ResolverPlaygroundTestCase( ["=sci-libs/K-2"], - options = {"--autounmask": True}, - success = True, - mergelist = ["sci-libs/P-1", "sci-libs/K-2"]), + options={"--autounmask": True}, + success=True, + mergelist=["sci-libs/P-1", "sci-libs/K-2"]), ResolverPlaygroundTestCase( ["=sci-libs/K-3"], - options = {"--autounmask": True}, - success = True, - mergelist = ["sci-libs/P-1", "sci-libs/K-3"]), + options={"--autounmask": True}, + success=True, + mergelist=["sci-libs/P-1", "sci-libs/K-3"]), ResolverPlaygroundTestCase( ["=sci-libs/K-4"], - options = {"--autounmask": True}, - success = True, - mergelist = ["sci-libs/P-1", "sci-libs/K-4"]), + options={"--autounmask": True}, + success=True, + mergelist=["sci-libs/P-1", "sci-libs/K-4"]), ResolverPlaygroundTestCase( ["=sci-libs/K-5"], - options = {"--autounmask": True}, - success = True, - mergelist = ["sci-libs/P-1", "sci-libs/K-5"]), + options={"--autounmask": True}, + success=True, + mergelist=["sci-libs/P-1", "sci-libs/K-5"]), ResolverPlaygroundTestCase( ["=sci-libs/K-6"], - options = {"--autounmask": True}, - success = True, - mergelist = ["sci-libs/P-1", "sci-libs/K-6"]), + options={"--autounmask": True}, + success=True, + mergelist=["sci-libs/P-1", "sci-libs/K-6"]), #Make sure we prefer use changes over keyword changes. ResolverPlaygroundTestCase( ["=sci-libs/K-7"], - options = {"--autounmask": True}, - success = False, - mergelist = ["sci-libs/L-1", "sci-libs/K-7"], - use_changes = { "sci-libs/L-1": { "bar": True } }), + options={"--autounmask": True}, + success=False, + mergelist=["sci-libs/L-1", "sci-libs/K-7"], + use_changes={ "sci-libs/L-1": { "bar": True } }), ResolverPlaygroundTestCase( ["=sci-libs/K-8"], - options = {"--autounmask": True}, - success = False, - mergelist = ["sci-libs/L-1", "sci-libs/K-8"], - use_changes = { "sci-libs/L-1": { "bar": True } }), + options={"--autounmask": True}, + success=False, + mergelist=["sci-libs/L-1", "sci-libs/K-8"], + use_changes={ "sci-libs/L-1": { "bar": True } }), #Test these nice "required by cat/pkg[foo]" messages. ResolverPlaygroundTestCase( ["=dev-util/Q-1"], - options = {"--autounmask": True}, - success = False, - mergelist = ["dev-util/R-1", "dev-util/Q-1"], - use_changes = { "dev-util/R-1": { "bar": True } }), + options={"--autounmask": True}, + success=False, + mergelist=["dev-util/R-1", "dev-util/Q-1"], + use_changes={ "dev-util/R-1": { "bar": True } }), ResolverPlaygroundTestCase( ["=dev-util/Q-2"], - options = {"--autounmask": True}, - success = False, - mergelist = ["dev-util/R-1", "dev-util/Q-2"], - use_changes = { "dev-util/R-1": { "bar": True } }), + options={"--autounmask": True}, + success=False, + mergelist=["dev-util/R-1", "dev-util/Q-2"], + use_changes={ "dev-util/R-1": { "bar": True } }), #Test interaction with REQUIRED_USE. ResolverPlaygroundTestCase( ["=app-portage/A-1"], - options = { "--autounmask": True }, - use_changes = None, - success = False), + options={ "--autounmask": True }, + use_changes=None, + success=False), ResolverPlaygroundTestCase( ["=app-portage/A-2"], - options = { "--autounmask": True }, - use_changes = None, - success = False), + options={ "--autounmask": True }, + use_changes=None, + success=False), ResolverPlaygroundTestCase( ["=app-portage/C-1"], - options = { "--autounmask": True }, - use_changes = None, - success = False), + options={ "--autounmask": True }, + use_changes=None, + success=False), #Make sure we don't change masked/forced flags. ResolverPlaygroundTestCase( ["dev-libs/E:1"], - options = {"--autounmask": True}, - use_changes = None, - success = False), + options={"--autounmask": True}, + use_changes=None, + success=False), ResolverPlaygroundTestCase( ["dev-libs/E:2"], - options = {"--autounmask": True}, - use_changes = None, - success = False), + options={"--autounmask": True}, + use_changes=None, + success=False), #Test mask and keyword changes. ResolverPlaygroundTestCase( ["app-text/A"], - options = {"--autounmask": True}, - success = False, - mergelist = ["app-text/A-1"], - needed_p_mask_changes = ["app-text/A-1"]), + options={"--autounmask": True}, + success=False, + mergelist=["app-text/A-1"], + needed_p_mask_changes=["app-text/A-1"]), ResolverPlaygroundTestCase( ["app-text/B"], - options = {"--autounmask": True}, - success = False, - mergelist = ["app-text/B-1"], - unstable_keywords = ["app-text/B-1"], - needed_p_mask_changes = ["app-text/B-1"]), + options={"--autounmask": True}, + success=False, + mergelist=["app-text/B-1"], + unstable_keywords=["app-text/B-1"], + needed_p_mask_changes=["app-text/B-1"]), ResolverPlaygroundTestCase( ["app-text/C"], - options = {"--autounmask": True}, - success = False, - mergelist = ["app-text/C-1"], - unstable_keywords = ["app-text/C-1"], - needed_p_mask_changes = ["app-text/C-1"]), + options={"--autounmask": True}, + success=False, + mergelist=["app-text/C-1"], + unstable_keywords=["app-text/C-1"], + needed_p_mask_changes=["app-text/C-1"]), #Make sure unstable keyword is preferred over missing keyword ResolverPlaygroundTestCase( ["app-text/D"], - options = {"--autounmask": True}, - success = False, - mergelist = ["app-text/D-1"], - unstable_keywords = ["app-text/D-1"]), + options={"--autounmask": True}, + success=False, + mergelist=["app-text/D-1"], + unstable_keywords=["app-text/D-1"]), #Test missing keyword ResolverPlaygroundTestCase( ["=app-text/D-2"], - options = {"--autounmask": True}, - success = False, - mergelist = ["app-text/D-2"], - unstable_keywords = ["app-text/D-2"]) + options={"--autounmask": True}, + success=False, + mergelist=["app-text/D-2"], + unstable_keywords=["app-text/D-2"]) ) profile = { @@ -279,7 +279,7 @@ class AutounmaskTestCase(TestCase): "dev-libs/A-1": { "LICENSE": "TEST" }, "dev-libs/B-1": { "LICENSE": "TEST", "IUSE": "foo", "KEYWORDS": "~x86"}, "dev-libs/C-1": { "DEPEND": "dev-libs/B[foo]", "EAPI": 2 }, - + "dev-libs/D-1": { "DEPEND": "dev-libs/E dev-libs/F", "LICENSE": "TEST" }, "dev-libs/E-1": { "LICENSE": "TEST" }, "dev-libs/E-2": { "LICENSE": "TEST" }, @@ -292,40 +292,40 @@ class AutounmaskTestCase(TestCase): test_cases = ( ResolverPlaygroundTestCase( ["=dev-libs/A-1"], - options = {"--autounmask": 'n'}, - success = False), + options={"--autounmask": 'n'}, + success=False), ResolverPlaygroundTestCase( ["=dev-libs/A-1"], - options = {"--autounmask": True}, - success = False, - mergelist = ["dev-libs/A-1"], - license_changes = { "dev-libs/A-1": set(["TEST"]) }), + options={"--autounmask": True}, + success=False, + mergelist=["dev-libs/A-1"], + license_changes={ "dev-libs/A-1": set(["TEST"]) }), #Test license+keyword+use change at once. ResolverPlaygroundTestCase( ["=dev-libs/C-1"], - options = {"--autounmask": True}, - success = False, - mergelist = ["dev-libs/B-1", "dev-libs/C-1"], - license_changes = { "dev-libs/B-1": set(["TEST"]) }, - unstable_keywords = ["dev-libs/B-1"], - use_changes = { "dev-libs/B-1": { "foo": True } }), + options={"--autounmask": True}, + success=False, + mergelist=["dev-libs/B-1", "dev-libs/C-1"], + license_changes={ "dev-libs/B-1": set(["TEST"]) }, + unstable_keywords=["dev-libs/B-1"], + use_changes={ "dev-libs/B-1": { "foo": True } }), #Test license with backtracking. ResolverPlaygroundTestCase( ["=dev-libs/D-1"], - options = {"--autounmask": True}, - success = False, - mergelist = ["dev-libs/E-1", "dev-libs/F-1", "dev-libs/D-1"], - license_changes = { "dev-libs/D-1": set(["TEST"]), "dev-libs/E-1": set(["TEST"]), "dev-libs/E-2": set(["TEST"]), "dev-libs/F-1": set(["TEST"]) }), + options={"--autounmask": True}, + success=False, + mergelist=["dev-libs/E-1", "dev-libs/F-1", "dev-libs/D-1"], + license_changes={ "dev-libs/D-1": set(["TEST"]), "dev-libs/E-1": set(["TEST"]), "dev-libs/E-2": set(["TEST"]), "dev-libs/F-1": set(["TEST"]) }), #Test license only for bug #420847 ResolverPlaygroundTestCase( ["dev-java/sun-jdk"], - options = {"--autounmask": True}, - success = False, - mergelist = ["dev-java/sun-jdk-1.6.0.31"], - license_changes = { "dev-java/sun-jdk-1.6.0.31": set(["TEST"]) }), + options={"--autounmask": True}, + success=False, + mergelist=["dev-java/sun-jdk-1.6.0.31"], + license_changes={ "dev-java/sun-jdk-1.6.0.31": set(["TEST"]) }), ) playground = ResolverPlayground(ebuilds=ebuilds) @@ -348,7 +348,7 @@ class AutounmaskTestCase(TestCase): "dev-libs/D-1": { "DEPEND": "dev-libs/A" }, } - world_sets = [ "@test-set" ] + world_sets = ["@test-set"] sets = { "test-set": ( "dev-libs/A", "dev-libs/B", "dev-libs/C", "dev-libs/D", @@ -362,29 +362,29 @@ class AutounmaskTestCase(TestCase): ResolverPlaygroundTestCase( ["dev-libs/B", "dev-libs/C", "dev-libs/D"], all_permutations=True, - options = {"--autounmask": "y"}, + options={"--autounmask": "y"}, mergelist=["dev-libs/A-2", "dev-libs/B-1", "dev-libs/C-1", "dev-libs/D-1"], ignore_mergelist_order=True, - unstable_keywords = ["dev-libs/A-2"], - success = False), + unstable_keywords=["dev-libs/A-2"], + success=False), ResolverPlaygroundTestCase( ["@test-set"], all_permutations=True, - options = {"--autounmask": "y"}, + options={"--autounmask": "y"}, mergelist=["dev-libs/A-2", "dev-libs/B-1", "dev-libs/C-1", "dev-libs/D-1"], ignore_mergelist_order=True, - unstable_keywords = ["dev-libs/A-2"], - success = False), + unstable_keywords=["dev-libs/A-2"], + success=False), ResolverPlaygroundTestCase( ["@world"], all_permutations=True, - options = {"--autounmask": "y"}, + options={"--autounmask": "y"}, mergelist=["dev-libs/A-2", "dev-libs/B-1", "dev-libs/C-1", "dev-libs/D-1"], ignore_mergelist_order=True, - unstable_keywords = ["dev-libs/A-2"], - success = False), + unstable_keywords=["dev-libs/A-2"], + success=False), ) @@ -411,16 +411,16 @@ class AutounmaskTestCase(TestCase): #Test mask and keyword changes. ResolverPlaygroundTestCase( ["app-text/A"], - options = {"--autounmask": True, - "--autounmask-keep-masks": "y"}, - success = False), + options={"--autounmask": True, + "--autounmask-keep-masks": "y"}, + success=False), ResolverPlaygroundTestCase( ["app-text/A"], - options = {"--autounmask": True, - "--autounmask-keep-masks": "n"}, - success = False, - mergelist = ["app-text/A-1"], - needed_p_mask_changes = ["app-text/A-1"]), + options={"--autounmask": True, + "--autounmask-keep-masks": "n"}, + success=False, + mergelist=["app-text/A-1"], + needed_p_mask_changes=["app-text/A-1"]), ) profile = { @@ -460,16 +460,16 @@ class AutounmaskTestCase(TestCase): test_cases = ( ResolverPlaygroundTestCase( ["dev-libs/B"], - success = False, - mergelist = ["dev-libs/A-2", "dev-libs/B-1"], - needed_p_mask_changes = set(["dev-libs/A-2"])), + success=False, + mergelist=["dev-libs/A-2", "dev-libs/B-1"], + needed_p_mask_changes=set(["dev-libs/A-2"])), ResolverPlaygroundTestCase( ["dev-libs/C"], - success = False, - mergelist = ["dev-libs/A-9999", "dev-libs/C-1"], - unstable_keywords = set(["dev-libs/A-9999"]), - needed_p_mask_changes = set(["dev-libs/A-9999"])), + success=False, + mergelist=["dev-libs/A-9999", "dev-libs/C-1"], + unstable_keywords=set(["dev-libs/A-9999"]), + needed_p_mask_changes=set(["dev-libs/A-9999"])), ) playground = ResolverPlayground(ebuilds=ebuilds, profile=profile) diff --git a/pym/portage/tests/resolver/test_backtracking.py b/pym/portage/tests/resolver/test_backtracking.py index 600f68216..53899eb48 100644 --- a/pym/portage/tests/resolver/test_backtracking.py +++ b/pym/portage/tests/resolver/test_backtracking.py @@ -85,7 +85,7 @@ class BacktrackingTestCase(TestCase): test_cases = ( ResolverPlaygroundTestCase( ["dev-libs/A"], - mergelist = ["dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1", ], + mergelist = ["dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1",], success = True), ) @@ -118,7 +118,7 @@ class BacktrackingTestCase(TestCase): ResolverPlaygroundTestCase( ["dev-libs/B", "dev-libs/A"], all_permutations = True, - mergelist = ["dev-libs/Z-2", "dev-libs/B-1", "dev-libs/A-1", ], + mergelist = ["dev-libs/Z-2", "dev-libs/B-1", "dev-libs/A-1",], ignore_mergelist_order = True, success = True), ) @@ -190,7 +190,7 @@ class BacktrackingTestCase(TestCase): "dev-libs/D-1": { "RDEPEND": " 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"), + 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"), ("1.001000000000000000001", "1.001000000000000000002"), ("1.00100000000", "1.0010000000000000001"), ("9999", "cvs.9999"), @@ -47,23 +49,25 @@ class VerCmpTestCase(TestCase): ("12.2b", "12.2.5"), ] for test in tests: - self.assertFalse( vercmp( test[0], test[1]) >= 0, msg="%s > %s? Wrong!" % (test[0],test[1])) - - + self.assertFalse(vercmp(test[0], test[1]) >= 0, msg="%s > %s? Wrong!" % (test[0], test[1])) + def testVerCmpEqual(self): - - tests = [ ("4.0", "4.0"), + + tests = [ + ("4.0", "4.0"), ("1.0", "1.0"), ("1.0-r0", "1.0"), ("1.0", "1.0-r0"), ("1.0-r0", "1.0-r0"), - ("1.0-r1", "1.0-r1")] + ("1.0-r1", "1.0-r1") + ] for test in tests: - self.assertFalse( vercmp( test[0], test[1]) != 0, msg="%s != %s? Wrong!" % (test[0],test[1])) - + self.assertFalse(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"), + + tests = [ + ("1", "2"), ("1.0_alpha", "1.0_pre"), ("1.0_beta", "1.0_alpha"), ("0", "0.0"), ("cvs.9999", "9999"), ("1.0-r0", "1.0-r1"), @@ -77,4 +81,4 @@ class VerCmpTestCase(TestCase): ("12.2b", "12.2"), ] for test in tests: - self.assertFalse( vercmp( test[0], test[1]) == 0, msg="%s == %s? Wrong!" % (test[0],test[1])) + self.assertFalse(vercmp(test[0], test[1]) == 0, msg="%s == %s? Wrong!" % (test[0], test[1])) -- 2.26.2