summaryrefslogtreecommitdiffstats
path: root/pym/portage/tests/__init__.py
diff options
context:
space:
mode:
authorSebastian Luther <SebastianLuther@gmx.de>2010-07-23 14:25:11 +0200
committerZac Medico <zmedico@gentoo.org>2010-07-23 09:47:13 -0700
commit01eb5fb39b7bf83aa3a75b34f48e6e48019ecba0 (patch)
tree5491e4545795a715c4089e0da6ed2bc1e5297404 /pym/portage/tests/__init__.py
parentb5b50e4193e2fb8aa7e5f3bd27fed41e2552697b (diff)
downloadportage-01eb5fb39b7bf83aa3a75b34f48e6e48019ecba0.tar.gz
portage-01eb5fb39b7bf83aa3a75b34f48e6e48019ecba0.tar.bz2
portage-01eb5fb39b7bf83aa3a75b34f48e6e48019ecba0.zip
portage.tests.TestCase: Add assertRaisesMsg() from pkgcore
Diffstat (limited to 'pym/portage/tests/__init__.py')
-rw-r--r--pym/portage/tests/__init__.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/pym/portage/tests/__init__.py b/pym/portage/tests/__init__.py
index 704847198..393ecf78c 100644
--- a/pym/portage/tests/__init__.py
+++ b/pym/portage/tests/__init__.py
@@ -154,6 +154,23 @@ class TestCase(unittest.TestCase):
if ok: result.addSuccess(self)
finally:
result.stopTest(self)
+
+ def assertRaisesMsg(self, msg, excClass, callableObj, *args, **kwargs):
+ """Fail unless an exception of class excClass is thrown
+ by callableObj when invoked with arguments args and keyword
+ arguments kwargs. If a different type of exception is
+ thrown, it will not be caught, and the test case will be
+ deemed to have suffered an error, exactly as for an
+ unexpected exception.
+ """
+ try:
+ callableObj(*args, **kwargs)
+ except excClass:
+ return
+ else:
+ if hasattr(excClass,'__name__'): excName = excClass.__name__
+ else: excName = str(excClass)
+ raise self.failureException("%s not raised: %s" % (excName, msg))
class TextTestRunner(unittest.TextTestRunner):
"""