public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/tests/
Date: Tue, 19 Jul 2011 09:56:40 +0000 (UTC)	[thread overview]
Message-ID: <83015161092c221d4440cba8a6aec5c325581011.mgorny@gentoo> (raw)

commit:     83015161092c221d4440cba8a6aec5c325581011
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 19 09:26:42 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Jul 19 09:26:42 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=83015161

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 = val
 
-	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]))
 
+	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)
 
 	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)
 
 	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)
 
 	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)
 
 class PMTestSuiteFactory(object):
 	def __init__(self, pm):



             reply	other threads:[~2011-07-19  9:56 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-19  9:56 Michał Górny [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-11-29  8:57 [gentoo-commits] proj/gentoopm:master commit in: gentoopm/tests/ Michał Górny
2014-11-29  8:57 Michał Górny
2014-11-29  8:57 Michał Górny
2012-12-10 20:58 Michał Górny
2012-12-10 17:36 Michał Górny
2012-01-09 16:09 Michał Górny
2011-12-09 15:09 Michał Górny
2011-07-25 17:06 Michał Górny
2011-07-20  9:41 Michał Górny
2011-07-19  9:56 Michał Górny
2011-07-17 22:19 Michał Górny
2011-07-15 13:32 Michał Górny
2011-07-15 13:32 Michał Górny
2011-07-15 12:34 Michał Górny
2011-07-15  9:52 Michał Górny
2011-07-15  9:52 Michał Górny
2011-07-15  9:52 Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83015161092c221d4440cba8a6aec5c325581011.mgorny@gentoo \
    --to=mgorny@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox