def testInterceptionException(self): def f(): raise NotImplementedError() def interceptor(f, *fargs, **fkwargs): return f(*fargs, **fkwargs) with ed.get_next_interceptor() as top_interceptor: old_interceptor = top_interceptor with self.assertRaises(NotImplementedError): with ed.interception(interceptor): f() with ed.get_next_interceptor() as top_interceptor: new_interceptor = top_interceptor self.assertEqual(old_interceptor, new_interceptor)