[testlib] Remove old TestCase.assertRaises code

It's been deprecated for 5 years, let it go. Related to #1716063.

authorRémi Cardona <remi.cardona@logilab.fr>
changeset2432940f1e7e
branchdefault
phasepublic
hiddenno
parent revision#687b0d3e2aaa [configuration] Have a stable order for sections (closes #298658)
child revision#46afffcb247b [testlib] Remove deprecated assert methods
files modified by this revision
logilab/common/testlib.py
# HG changeset patch
# User Rémi Cardona <remi.cardona@logilab.fr>
# Date 1441891772 -7200
# Thu Sep 10 15:29:32 2015 +0200
# Node ID 2432940f1e7e40482823d83b3580448cafd35e3b
# Parent 687b0d3e2aaab81cbfd36ba49830ff6f92618deb
[testlib] Remove old TestCase.assertRaises code

It's been deprecated for 5 years, let it go. Related to #1716063.

diff --git a/logilab/common/testlib.py b/logilab/common/testlib.py
@@ -1064,57 +1064,10 @@
1              msg = "%r != %r" % (obj, other)
2          if relative:
3              prec = prec*math.fabs(obj)
4          self.assertTrue(math.fabs(obj - other) < prec, msg)
5 
6 -    def failUnlessRaises(self, excClass, callableObj=None, *args, **kwargs):
7 -        """override default failUnlessRaises method to return the raised
8 -        exception instance.
9 -
10 -        Fail unless an exception of class excClass is thrown
11 -        by callableObj when invoked with arguments args and keyword
12 -        arguments kwargs. If a different type of exception is
13 -        thrown, it will not be caught, and the test case will be
14 -        deemed to have suffered an error, exactly as for an
15 -        unexpected exception.
16 -
17 -        CAUTION! There are subtle differences between Logilab and unittest2
18 -        - exc is not returned in standard version
19 -        - context capabilities in standard version
20 -        - try/except/else construction (minor)
21 -
22 -        :param excClass: the Exception to be raised
23 -        :param callableObj: a callable Object which should raise <excClass>
24 -        :param args: a List of arguments for <callableObj>
25 -        :param kwargs: a List of keyword arguments  for <callableObj>
26 -        """
27 -        # XXX cube vcslib : test_branches_from_app
28 -        if callableObj is None:
29 -            _assert = super(TestCase, self).assertRaises
30 -            return _assert(excClass, callableObj, *args, **kwargs)
31 -        try:
32 -            callableObj(*args, **kwargs)
33 -        except excClass as exc:
34 -            class ProxyException:
35 -                def __init__(self, obj):
36 -                    self._obj = obj
37 -                def __getattr__(self, attr):
38 -                    warn_msg = ("This exception was retrieved with the old testlib way "
39 -                                "`exc = self.assertRaises(Exc, callable)`, please use "
40 -                                "the context manager instead'")
41 -                    warnings.warn(warn_msg, DeprecationWarning, 2)
42 -                    return self._obj.__getattribute__(attr)
43 -            return ProxyException(exc)
44 -        else:
45 -            if hasattr(excClass, '__name__'):
46 -                excName = excClass.__name__
47 -            else:
48 -                excName = str(excClass)
49 -            raise self.failureException("%s not raised" % excName)
50 -
51 -    assertRaises = failUnlessRaises
52 -
53      if sys.version_info >= (3,2):
54          assertItemsEqual = unittest.TestCase.assertCountEqual
55      else:
56          assertCountEqual = unittest.TestCase.assertItemsEqual
57          if sys.version_info < (2,7):