MCPcopy Index your code
hub / github.com/RustPython/RustPython / handle

Method handle

Lib/unittest/case.py:228–255  ·  view source on GitHub ↗

If args is empty, assertRaises/Warns is being used as a context manager, so check for a 'msg' kwarg and return self. If args is not empty, call a callable passing positional and keyword arguments.

(self, name, args, kwargs)

Source from the content-addressed store, hash-verified

226 self.msg = None
227
228 def handle(self, name, args, kwargs):
229 """
230 If args is empty, assertRaises/Warns is being used as a
231 context manager, so check for a 'msg' kwarg and return self.
232 If args is not empty, call a callable passing positional and keyword
233 arguments.
234 """
235 try:
236 if not _is_subtype(self.expected, self._base_type):
237 raise TypeError('%s() arg 1 must be %s' %
238 (name, self._base_type_str))
239 if not args:
240 self.msg = kwargs.pop('msg', None)
241 if kwargs:
242 raise TypeError('%r is an invalid keyword argument for '
243 'this function' % (next(iter(kwargs)),))
244 return self
245
246 callable_obj, *args = args
247 try:
248 self.obj_name = callable_obj.__name__
249 except AttributeError:
250 self.obj_name = str(callable_obj)
251 with self:
252 callable_obj(*args, **kwargs)
253 finally:
254 # bpo-23890: manually break a reference cycle
255 self = None
256
257
258class _AssertRaisesContext(_AssertRaisesBaseContext):

Callers 5

assertRaisesMethod · 0.45
assertWarnsMethod · 0.45
_assertNotWarnsMethod · 0.45
assertRaisesRegexMethod · 0.45
assertWarnsRegexMethod · 0.45

Calls 5

_is_subtypeFunction · 0.85
nextFunction · 0.85
iterFunction · 0.85
strFunction · 0.85
popMethod · 0.45

Tested by

no test coverage detected