From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Qhf4z-0007f7-H3 for garchives@archives.gentoo.org; Fri, 15 Jul 2011 09:53:05 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id ED7E721C135; Fri, 15 Jul 2011 09:52:27 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id AC7C221C130 for ; Fri, 15 Jul 2011 09:52:27 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id EE6002AC310 for ; Fri, 15 Jul 2011 09:52:26 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 2ED9C8003D for ; Fri, 15 Jul 2011 09:52:26 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <96d43547ff234a34aa2c8dff8c981662d5cd5e5d.mgorny@gentoo> Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/tests/ X-VCS-Repository: proj/gentoopm X-VCS-Files: gentoopm/tests/__init__.py gentoopm/tests/atom.py X-VCS-Directories: gentoopm/tests/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 96d43547ff234a34aa2c8dff8c981662d5cd5e5d Date: Fri, 15 Jul 2011 09:52:26 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 335fcbaf8d4613d0307ca0a9a2dced6f commit: 96d43547ff234a34aa2c8dff8c981662d5cd5e5d Author: Micha=C5=82 G=C3=B3rny gentoo org> AuthorDate: Fri Jul 15 08:50:26 2011 +0000 Commit: Micha=C5=82 G=C3=B3rny gentoo org> CommitDate: Fri Jul 15 08:50:26 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gentoopm.git;= a=3Dcommit;h=3D96d43547 Tests: keep real package names in separate module. --- gentoopm/tests/__init__.py | 15 +++++++++++++++ gentoopm/tests/atom.py | 9 ++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/gentoopm/tests/__init__.py b/gentoopm/tests/__init__.py index 40f0b75..f430917 100644 --- a/gentoopm/tests/__init__.py +++ b/gentoopm/tests/__init__.py @@ -36,3 +36,18 @@ class PMTestLoader(unittest.TestLoader): if isinstance(mod, basestring): mod =3D __import__(mod, fromlist=3D['.'], level=3D-1) return unittest.TestLoader.loadTestsFromModule(self, mod) + +class PackageNames(object): + """ + A container for package names used in tests. Supposed to allow simple + switch to another packages when one of them stops to work. + """ + + single =3D 'portage' + """ Incomplete atom matching a single package. """ + + single_complete =3D 'sys-apps/portage' + """ Complete atom matching a single package. """ + + multiple =3D 'pms' + """ Incomplete atom matching multiple packages. """ diff --git a/gentoopm/tests/atom.py b/gentoopm/tests/atom.py index bee882d..53e7045 100644 --- a/gentoopm/tests/atom.py +++ b/gentoopm/tests/atom.py @@ -4,12 +4,12 @@ # Released under the terms of the 2-clause BSD license. =20 from gentoopm.exceptions import InvalidAtomStringError, AmbiguousPackage= SetError -from gentoopm.tests import PMTestCase +from gentoopm.tests import PMTestCase, PackageNames =20 class UserSpecifiedAtomTestCase(PMTestCase): def setUp(self): - self._incomplete_atom =3D self.pm.Atom('portage') - self._complete_atom =3D self.pm.Atom('sys-apps/portage') + self._incomplete_atom =3D self.pm.Atom(PackageNames.single) + self._complete_atom =3D self.pm.Atom(PackageNames.single_complete) self._associated_atom =3D self._complete_atom.get_associated(self.pm.s= tack) =20 def test_invalid_atoms(self): @@ -42,8 +42,7 @@ class UserSpecifiedAtomTestCase(PMTestCase): self.assertEqual(a.associated, True) =20 def test_ambiguous_atom_association(self): - # XXX: risky - ia =3D self.pm.Atom('pms') + ia =3D self.pm.Atom(PackageNames.multiple) self.assertRaises(AmbiguousPackageSetError, ia.get_associated, self.pm.stack) =20