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 1Qj72n-0002hW-CC for garchives@archives.gentoo.org; Tue, 19 Jul 2011 09:56:50 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C67AA21C107; Tue, 19 Jul 2011 09:56:41 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 9A6EB21C107 for ; Tue, 19 Jul 2011 09:56:41 +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 1A48C1B4011 for ; Tue, 19 Jul 2011 09:56:41 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 643F88003F for ; Tue, 19 Jul 2011 09:56:40 +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: <83015161092c221d4440cba8a6aec5c325581011.mgorny@gentoo> Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/tests/ X-VCS-Repository: proj/gentoopm X-VCS-Files: gentoopm/tests/__init__.py X-VCS-Directories: gentoopm/tests/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 83015161092c221d4440cba8a6aec5c325581011 Date: Tue, 19 Jul 2011 09:56:40 +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: 1d6a94f7c3c196774d5b56978ff1f625 commit: 83015161092c221d4440cba8a6aec5c325581011 Author: Micha=C5=82 G=C3=B3rny gentoo org> AuthorDate: Tue Jul 19 09:26:42 2011 +0000 Commit: Micha=C5=82 G=C3=B3rny gentoo org> CommitDate: Tue Jul 19 09:26:42 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gentoopm.git;= a=3Dcommit;h=3D83015161 Commonize assert wrapping code. --- gentoopm/tests/__init__.py | 27 +++++++++------------------ 1 files changed, 9 insertions(+), 18 deletions(-) diff --git a/gentoopm/tests/__init__.py b/gentoopm/tests/__init__.py index 08f50b7..fbb773f 100644 --- a/gentoopm/tests/__init__.py +++ b/gentoopm/tests/__init__.py @@ -18,35 +18,26 @@ class PMTestCase(unittest.TestCase): assert(self._pm is None) self._pm =3D val =20 - def assertEqual(self, *args): + def _try(self, f, args): try: - unittest.TestCase.assertEqual(self, *args) + f(self, *args) except AssertionError as e: raise AssertionError('[%s] %s' % (self._pm.name, e.args[0])) =20 + def assertEqual(self, *args): + self._try(unittest.TestCase.assertEqual, args) + def assertNotEqual(self, *args): - try: - unittest.TestCase.assertNotEqual(self, *args) - except AssertionError as e: - raise AssertionError('[%s] %s' % (self._pm.name, e.args[0])) + self._try(unittest.TestCase.assertNotEqual, args) =20 def assertTrue(self, *args): - try: - unittest.TestCase.assertTrue(self, *args) - except AssertionError as e: - raise AssertionError('[%s] %s' % (self._pm.name, e.args[0])) + self._try(unittest.TestCase.assertTrue, args) =20 def assertFalse(self, *args): - try: - unittest.TestCase.assertFalse(self, *args) - except AssertionError as e: - raise AssertionError('[%s] %s' % (self._pm.name, e.args[0])) + self._try(unittest.TestCase.assertFalse, args) =20 def assertRaises(self, *args): - try: - unittest.TestCase.assertRaises(self, *args) - except AssertionError as e: - raise AssertionError('[%s] %s' % (self._pm.name, e.args[0])) + self._try(unittest.TestCase.assertRaises, args) =20 class PMTestSuiteFactory(object): def __init__(self, pm):