From a21a01fde3c1225572773cb73232229d3505266a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Cardona?= Date: Thu, 10 Sep 2015 15:29:32 +0200 Subject: [testlib] Remove old TestCase.assertRaises code It's been deprecated for 5 years, let it go. Related to #1716063. --- logilab/common/testlib.py | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) (limited to 'logilab') diff --git a/logilab/common/testlib.py b/logilab/common/testlib.py index a6b4b1e..a7724de 100644 --- a/logilab/common/testlib.py +++ b/logilab/common/testlib.py @@ -1066,53 +1066,6 @@ class TestCase(unittest.TestCase): prec = prec*math.fabs(obj) self.assertTrue(math.fabs(obj - other) < prec, msg) - def failUnlessRaises(self, excClass, callableObj=None, *args, **kwargs): - """override default failUnlessRaises method to return the raised - exception instance. - - 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. - - CAUTION! There are subtle differences between Logilab and unittest2 - - exc is not returned in standard version - - context capabilities in standard version - - try/except/else construction (minor) - - :param excClass: the Exception to be raised - :param callableObj: a callable Object which should raise - :param args: a List of arguments for - :param kwargs: a List of keyword arguments for - """ - # XXX cube vcslib : test_branches_from_app - if callableObj is None: - _assert = super(TestCase, self).assertRaises - return _assert(excClass, callableObj, *args, **kwargs) - try: - callableObj(*args, **kwargs) - except excClass as exc: - class ProxyException: - def __init__(self, obj): - self._obj = obj - def __getattr__(self, attr): - warn_msg = ("This exception was retrieved with the old testlib way " - "`exc = self.assertRaises(Exc, callable)`, please use " - "the context manager instead'") - warnings.warn(warn_msg, DeprecationWarning, 2) - return self._obj.__getattribute__(attr) - return ProxyException(exc) - else: - if hasattr(excClass, '__name__'): - excName = excClass.__name__ - else: - excName = str(excClass) - raise self.failureException("%s not raised" % excName) - - assertRaises = failUnlessRaises - if sys.version_info >= (3,2): assertItemsEqual = unittest.TestCase.assertCountEqual else: -- cgit v1.2.1